问题
selectpicker
$('.selectpicker').selectpicker();
$("#s1").addClass("btn-sm");
//set to current value$("#s1").selectpicker('val', picker[0]["f_name"]);
$("#s1").selectpicker("refresh");
select picker css
<div id="input1" style="margin-bottom: 50px">
<div class="pull-left" style="width: 250px;">
<select class="selectpicker" data-live-search="true" id="s1">
</select>
This is my code. I want to set a search in my select picker. What should I do?
回答1:
<div class="live-search" >
<select class="selectpicker" data-live-search="true" >
<option data-tokens="text" >text</option>
</select>
</div>
You have to add src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/js/bootstrap-select.min.js"
回答2:
selectpicker function should be on ready method of jquery.
Also try
$('.selectpicker').selectpicker({
liveSearch: true
});
instead of data-live-search="true" in html.
来源:https://stackoverflow.com/questions/41717660/trying-to-set-data-live-search-to-select-picker