davidstutz / bootstrap-multiselect

JQuery multiselect plugin based on Twitter Bootstrap.
https://davidstutz.github.io/bootstrap-multiselect/
Other
3.67k stars 1.98k forks source link

Question about deselect option #1274

Closed Renaud6322 closed 10 months ago

Renaud6322 commented 10 months ago

Hi and thanks for this nice plugin. I would like to unselect all options if a specific one is selected. Is it possible ? I did that but it's not working (just tried to deselect an option for test)

onChange:function (option, checked) {
    if(option.val() == 'memo' && checked == true){
        console.log(option.val() + " " +checked);
        $('#select-dests').multiselect('deselect', 'client');

    }
},

Could you help me ? Best regards. Renaud.

tiesont commented 10 months ago

deselect un-selects the option matching the value provided as the second parameter. If you're trying to un-select every option, you want to use deselectAll:

Deselects all options. If justVisible is set to true or not provided, all visible options are deselected, otherwise (justVisible set to false) all options are deselected.

Renaud6322 commented 10 months ago

Thank you so much for the answer !

This code

onChange:function (option, checked) { if(option.val() == 'memo' && checked == true){ $('#select-dests').multiselect('deselectAll'); } }, Uncheck all checkboxes when "memo" is checked, it's parefect. But the problem is "memo" is uncheckeable.