Search code examples
jquerysliderrangeslider

Jquery change function on ionslider not working


I have a ionslider in my project. I need to predict the slider change. This is my slider

$("#myslider").ionRangeSlider();

on change function

$("#myslider").on('change',function(){
    var $this = $(this),
    from = $this.data("from"),
    to = $this.data("to");

   console.log(from + " - " + to);
});

But 'change' function not working. Is this a correct way to predict the slider change? or is there anyway to do.. Thanks


Solution

  • You should use the onChange event of ionRangeSlider:

    $("#range_43").ionRangeSlider({
        type: "single",
        min: 0,
        max: 100,
        from: 50,
        keyboard: true,
        onStart: function(data) {
            console.log("onStart");
        },
        onChange: function(data) {
            console.log("onChange");
        },
        onFinish: function(data) {
            console.log("onFinish");
        },
        onUpdate: function(data) {
            console.log("onUpdate");
        }
    });
    

    http://ionden.com/a/plugins/ion.rangeSlider/demo_interactions.html