wenzhixin / multiple-select

A jQuery plugin to select multiple elements with checkboxes :)
http://multiple-select.wenzhixin.net.cn
MIT License
1.91k stars 651 forks source link

MultiSelect Checkbox Postback Issue #417

Closed SriFNDR closed 5 years ago

SriFNDR commented 5 years ago

Hi,

I am using multiselect checkbox filter with search option. My browser is IE 8. When I select items on multiselect control and click on a button, all the selected items will disappear. I think this is due to the postback event happening due to the button click. Could you please help out on this. I tried to rebind the items by getting the selected item from control. but it didn't work. Here is the code snippet. Only one item was getting selected

Solution :1

var arryselecteitems = $("#dropdowid").multipleSelect('getSelects', 'text')
    for(var i=0 ;i<arryselecteitems .length;i++)
          {

                $('#dropdowid').multipleSelect('setSelects',  [arryselecteitems [i]]);
           }
  $('#dropdowid').multipleSelect('refresh');

Solution : 2 Other than the above solution i used the below Reference Link :https://github.com/wenzhixin/multiple-select/issues/367

$("#chapterID").siblings(".ms-parent").remove();

And then clear associated JQuery data attached to the select element

$("#chapterID").removeData();

Then I could reinstate a new multiple selection instance of a different selection type e.g. your

var chapter = jQuery('#chapterId').multipleSelect({
  filter: true,
  single: false;
});

But this keeps on adding new controls on button click, as we are intializing new instance.

wenzhixin commented 5 years ago

Added refreshOptions method to solve the problem. Fixed in #458