snapappointments / bootstrap-select

:rocket: The jQuery plugin that brings select elements into the 21st century with intuitive multiselection, searching, and much more.
https://developer.snapappointments.com/bootstrap-select/
MIT License
9.85k stars 2.72k forks source link

Not able to "refresh" #2654

Open kapdom opened 3 years ago

kapdom commented 3 years ago

Hi. If I add attribute "selected" to one of the option on the server side then I'm not able to reset selected value.

<select name="shop_id" class="my-select" data-width="100%" data-size="5" data-live-search="true" title="Select"> @foreach(shops() as $row) <option value="{{$row->id}}" @if($row->id == $shop_id) selected @endif>{{$row->name}}</option> @endforeach </select> How to reset it if one of the option had selected attribute?

NicolasCARPi commented 3 years ago

Hello,

I don't think it has anything to do with the fact that the selected attribute is added server side. What do you mean by "reset the selected value"?

kapdom commented 3 years ago

I mean this "$(citySelect).selectpicker('refresh');"

NicolasCARPi commented 3 years ago

Can you confirm that if you don't have any element with the selected attribute, the refresh works?

kapdom commented 3 years ago

If I don't add selected attribute then works, perfectly.