calvinturbo

Fix for select multiple dropdown

Apr 7th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.60 KB | None | 0 0
  1.         // bug in materialize causing values in multi dropdown to not update, fix below
  2.         $('select').material_select();
  3.         $('select').change(function(){
  4.             var newValuesArr = [],
  5.                 select = $(this),
  6.                 ul = select.prev();
  7.             ul.children('li').toArray().forEach(function (li, i) {
  8.                 if ($(li).hasClass('active')) {
  9.                     newValuesArr.push(select.children('option').toArray()[i].value);
  10.                 }
  11.             });
  12.             //select.val(newValuesArr);
  13.             $(select).data('var', newValuesArr)
  14.         });
Advertisement
Add Comment
Please, Sign In to add comment