jQuery UI slider - Cannot call method 'addClass' of undefined

后端 未结 7 1407
我在风中等你
我在风中等你 2021-01-07 21:50

I had this old jQuery UI slider that had worked just fine a few months ago, but now I seem to be getting an exception reading: Cannot call method \'addClass\' of undefined.

相关标签:
7条回答
  • 2021-01-07 22:19

    jQuery UI Slider plugin min & max options accepts only number. So according to your requirement parse them to integer or float.

    For details visit link- http://api.jqueryui.com/slider/

    0 讨论(0)
  • 2021-01-07 22:20

    solved the problem using unmodified jQuery-UI.min.js. Using a custom script caused the error i.e jQuery-UI-custom.js

    0 讨论(0)
  • 2021-01-07 22:28

    For anyone who's still having this issue, ensure that the values you're adding (min, max, and values are all NUMBERS and not STRINGS!

    Been trying to diagnose a problem where the following code was failing:

    t.slider({
      range : true,
      min   : t.attr('data-min'),
      max   : t.attr('data-max'),
      values: [t.attr('data-min'), t.attr('data-max')],
      step  : 1.00,
      slide : function (e, ui) {
        var
          v = (s == 'price') ? '£' + ui.values[0] + ' - £' + ui.values[1] : ui.values[0] + ' - ' + ui.values[1] + 'kg'
        $('#filter-' + s).html(v)
      },
      stop  : function () {
        Items.filter()
      }
    })
    

    As t.attr() returns a STRING, Slider was failing to set valueMouse on line 12843 of Version 1.10.1 of jQuery UI. Instead of being a value, it was returning a string (something similar to 39.99549.21 (min value of 39.99 concatenated with 549.21 - a percentage * max value)

    Hope that helps someone!

    0 讨论(0)
  • 2021-01-07 22:29

    I had this issue with latest versions, too. The solution is easy: use parseInt() to pass dynamic values to sliders

    Setter example for jquery ui slider:

        $("#mySlider").slider("option",{min: parseInt(value.min), max:parseInt(value.max),value: parseInt(value.active)});
    
    0 讨论(0)
  • 2021-01-07 22:32

    Another possibility - this error can come up if the min or max are missing for the slider. If your startFiling or endFiling are not evaluating to a date, the slider code fails when trying to calculate the new handle position.

    0 讨论(0)
  • 2021-01-07 22:37

    For anyone reading back on this question, if you're pulling from a CDN, try pulling from the latest jQuery UI version. I also got this problem, and it was solved by using a later jQuery UI version.

    0 讨论(0)
提交回复
热议问题