Reputation: 57
I am using silviomoreto selectpicker. The problem is, it doesn't show the items when I click on the select.
Html Code :
<select id="tick1" multiple data-live-search="true" class="form-control selectpicker show-tick" name="tick1">
<option Value="" hidden selected="selected"></option>
<option Value="1">One</option>
<option Value="2">Two</option>
<option Value="3">Three</option>
</select>
JQuery Code :
<script type="text/javascript">
$(document).ready(function (e) {
$(".selectpicker").selectpicker();
});
</script>
The thing is, when I click on the selectpicker and press ctrl + d, the picker fires and I can use it but it won't close when I click anywhere else.
Thank you
Upvotes: 1
Views: 2546
Reputation: 93
I had the same problem many times. Adding the attribute data-container to select element should fix that behavior.
$("#tick1").selectpicker();
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<select id="tick1" multiple data-live-search="true" data-container="body" class="form-control selectpicker show-tick" name="tick1">
<option Value="" hidden selected="selected"></option>
<option Value="1">One</option>
<option Value="2">Two</option>
<option Value="3">Three</option>
</select>
Upvotes: 4