DeselectAll doesn't work for Bootstrap-select

demo picture demo · Feb 5, 2015 · Viewed 9.5k times · Source

Here is example what i try, but didn't work.

JsFiddle

What i expect : on button click all options will be unselected.

I try with "refresh" and "render" but also didn't help.

 <select class="selectpicker" multiple title="Not changable text" data-count-selected-text="Not changable text">
         <option>Mustard</option>
         <option>Ketchup</option>
         <option>Relish</option>
 </select>

<button id="f1">ggg</button>

$('#f1').click(function(){
   $('.selectpicker').selectpicker('deselectAll');
});

UPDATE : code doesn't work if select is closed. In case it's open - all is good

Answer

Artur Filipiak picture Artur Filipiak · Feb 5, 2015

EDIT

There was a bug with deselectAll and is now fixed


You can empty selection using val :

$('#f1').click(function(){
    $('.selectpicker').selectpicker('val', '');
});

DeselectAll should theoretically do the job, but for some reason it doesn't. (it does now)

DEMO