321 321 - 6 months ago 123
jQuery Question

Bootstrap Selectpicker problems

I'm trying to use this selectpicker for form selects and options, but can't get it to work.

I've added the following scripts and css as specified:

<script type="text/javascript">
$('.selectpicker').selectpicker({
});
</script>

<script src="/js/Bootstrap/Select/bootstrap-select.js"></script>


html for the 1st greyed out select in the search bar:

<select class="selectpicker" id="searchType" name="searchtype" onchange="this.form.submit()">
<option value="All">All</option>
<option value="Businesses">Businesses</option>
<option value="Events">Events</option>
<option value="News">News</option>
<option value="Lifestyle">Lifestyle</option>

</select>


Any ideas appreciated.

Answer

Please be sure that you included all the required files or You may have to rearrange the code like :

<script src="/js/Bootstrap/Select/bootstrap-select.js"></script>

<script type="text/javascript">
    $('.selectpicker').selectpicker({
      });
</script>

You need to include the js first then call the the plugin. Check this fiddle, its working for me : http://jsfiddle.net/tejashsoni111/RUAS4/