简体   繁体   中英

jQuery UI Multiselect widget clear all check boxes

Hopefully a quick one...

I need to fire the uncheckAll event in the click event of a separate button on my page, I have tried the following:

$('.masterProviderOrgsListBox').multiselect().uncheckAll();

but this isnt a recognised method. I basically want to fire the same method that is fired when you click the "Uncheck All" box in the header.

I was previously doing this:

$('.masterProviderOrgsListBox option:selected').removeAttr("selected");

but this removes the selections on the actual multiselect rather than the jQuery UI widget.

Couldnt find anything in the documentation, any ideas?

Methods

After an instance has been initialized, interact with it by calling any of these methods:

// example: $("#multiselect").multiselect("method_name");

...which can be found in the widgets documentation under Methods

$("#multiselect").multiselect("uncheckAll");

1) first, you need to set default value of the control.

jQuery('#multiselect').val("");

2) Then, execute below code to reset the control.

jQuery('#multiselect').multiselect("refresh");

$("#multiselectoption:selected").removeAttr("selected");
$("#multiselect").multiselect('refresh');

refresh should be call after clearing the drop down.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM