【问题标题】:Jquery change function on ionslider not working离子滑块上的Jquery更改功能不起作用
【发布时间】:2015-08-09 01:37:05
【问题描述】:

我的项目中有一个离子滑块。我需要预测滑块的变化。 这是我的滑块

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

关于改变功能

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

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

但是'change' 功能不起作用。这是预测滑块变化的正确方法吗?还是有什么可做的。。谢谢

【问题讨论】:

    标签: jquery slider rangeslider


    【解决方案1】:

    你应该使用 ionRangeSlider 的onChange 事件:

    $("#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

    【讨论】:

      【解决方案2】:

      你可以用这个:

      $("#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() 触发

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-03
        • 1970-01-01
        • 1970-01-01
        • 2015-06-18
        • 1970-01-01
        • 2021-01-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多