2015-05-27 36 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()