I am using jquery multiselect widget. I would like to uncheck all if all them were checked manually. I have a sample code in JSFiddle--> Code
This doesn't work. When the select options are selected manually, check for no of unchecked options in select it gives me 1 (at the click of last option) the first time. so I checked if $this.children("option").not('[selected]').length
is 1 and ui.checked
and calling the uncheckAll
but after that it is behaving properly the code
if $this.children("option").not('[selected]').length
gives me 0 when selecting the final one.
I am wondering what is happening.
well so here is the solution what you want... check the documentation , there is method getChecked
to get selected options
. yours is not working because the pluging reformat the select elements.
$('.multi').multiselect({
click: function(e, ui){
if($(this).multiselect("getChecked").length
== $('select.multi > option').length){
$(this).multiselect("uncheckAll");
}
}
});
fiddle example : http://jsfiddle.net/fG6PT/11/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With