Advertisement
bueddl

Untitled

Sep 29th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var settings = {
  2.             'createCallback':false,
  3.             'createText':false,
  4.             'singleSelect':false,
  5.             'selectedFirst':false,
  6.             'sort':true,
  7.             'title':this.attr('title'),
  8.             'checked':[],
  9.             'labels':[],
  10.             'oncheck':false,
  11.             'onuncheck':false,
  12.             'minWidth': 'default;',
  13.         };
  14.         $(this).attr('data-msid', multiSelectId);
  15.         $.extend(settings,options);
  16.         $.each(this.children(),function(i,option) {
  17.             // If the option is selected, but not in the checked array, add it.
  18.             if($(option).attr('selected') && settings.checked.indexOf($(option).val()) === -1) {
  19.                 settings.checked.push($(option).val());
  20.                 settings.labels.push($(option).text().trim());
  21.             }
  22.             // If the option is in the checked array but not selected, select it.
  23.             else if(settings.checked.indexOf($(option).val()) !== -1 && !$(option).attr('selected')) {
  24.                 $(option).attr('selected', 'selected');
  25.                 settings.labels.push($(option).text().trim());
  26.             }
  27.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement