multiselect.js compatibility with older jquery

720 Views Asked by At

The stated minimum level of compatibility of the multiselect.js jQuery library is with jQuery 1.8+

I'm wondering what part of the codebase causes this dependency and what could I do to make the script more backwards compatible.

For instance, when I try it with 1.3.2, the script breaks on 'split' function, called from within the 'each' function:

Uncaught TypeError: Cannot call method 'split' of undefined jquery-1.3.2.min.js:12
o.fn.extend.data     jquery-1.3.2.min.js:12
(anonymous function) jquery.multi-select.js:481
o.extend.each        jquery-1.3.2.min.js:12
o.fn.o.each          jquery-1.3.2.min.js:12
$.fn.multiSelect     jquery.multi-select.js:478

This section of code is what is causing the breakage:

return this.each(function () {  // this line
  var $this = $(this),
      data = $this.data('multiselect'),
      options = $.extend({}, $.fn.multiSelect.defaults, $this.data(), typeof option === 'object' && option);

  if (!data){ $this.data('multiselect', (data = new MultiSelect(this, options))); }

  if (typeof option === 'string'){
    data[option](args[1]);
  } else {
    data.init();
  }
});
0

There are 0 best solutions below