2015-05-27 40 views
1

我的項目中有一個離子風機。我需要預測滑塊更改。 這是我對改變功能滑塊jquery更改離子風機功能不起作用

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

不工作

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

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

'change'功能。這是預測滑塊更改的正確方法嗎?或者是反正有做..謝謝

回答

1

您應該使用onChange事件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

+0

@ Tushar ..感謝兄弟...它的工作很好.. – Gayathri

0

您可以使用此:

$("#myslider").change(function(){ 
    console.log("check"); //check if it successfully enters .change function 
    var $this = $(this), 
    from = $this.data("from"), 
    to = $this.data("to"); 

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

如果沒有繼續第二個控制檯日誌,你的變量值可能有問題。 .change應該通過觸發.ionRangeSlider()