Skip to content

Add a rzSliderOnChange attribute. #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ $scope.priceSlider = {

> Custom translate function. Use this if you want to translate values displayed on the slider. For example if you want to display dollar amounts instead of just numbers do this:

**rz-slider-on-change**

> Function to be called when rz-slider-model or rz-slider-high change.

```javascript
// In your controller

Expand All @@ -128,7 +132,8 @@ $scope.translate = function(value)
rz-slider-ceil="priceSlider.ceil"
rz-slider-model="priceSlider.min"
rz-slider-high="priceSlider.max"
rz-slider-translate="translate"></rzslider>
rz-slider-translate="translate"
rz-slider-on-change="onSliderChange()"></rzslider>
```

## Slider events
Expand Down
15 changes: 14 additions & 1 deletion rzslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,17 @@ function throttle(func, wait, options) {
this.getWidth(this.flrLab);
},

/**
* Call the onChange callback if defined
*
* @returns {undefined}
*/
callOnChange: function() {
if(this.scope.rzSliderOnChange) {
this.scope.rzSliderOnChange();
}
},

/**
* Update slider handles and label positions
*
Expand All @@ -568,6 +579,7 @@ function throttle(func, wait, options) {
*/
updateHandles: function(which, newOffset)
{
this.callOnChange();
if(which === 'rzSliderModel')
{
this.updateLowHandle(newOffset);
Expand Down Expand Up @@ -1033,7 +1045,8 @@ function throttle(func, wait, options) {
rzSliderTranslate: '&',
rzSliderHideLimitLabels: '=?',
rzSliderAlwaysShowBar: '=?',
rzSliderPresentOnly: '@'
rzSliderPresentOnly: '@',
rzSliderOnChange: '&'
},

/**
Expand Down