Search code examples
jqueryhtmltwitter-bootstrapbootstrap-slider

How can I detect state of boostrap slider?


I am using this library : https://github.com/seiyria/bootstrap-slider

I have my slider:

<input id="months" data-slider-id='monthsSlider' type="text" data-slider-min="5" data-slider-max="10" data-slider-step="1" data-slider-value="5" data-slider-handle="square" />

How can I detect when user clicks on slider handle and move it?


Solution

  • Here are the Events.

    Events

    slide
    This event fires when the slider is dragged

    slideStart
    This event fires when dragging start

    slideStop This event fires when the dragging stops or has been clicked on

    change
    This event fires when the slider value has changed

    slideEnabled
    This event fires when the slider is enabled

    slideDisabled

    This event fires when the slider is disabled

    so, you can use:-

    $('#months').on('slide', function(slideEvt) {
        var newValue = slideEvt.value;
    });