Search code examples
aspnetboilerplate

Form Select with AspnetBoilerplate BSB Theme


Can't get a styled select form element to display correctly with the AspnetBoilerplate BSB Theme and there is no examples of one being used in the code.

I do see in the stylesheet the .bootstrap-select styles. Does someone have an example of how to use this?


Solution

  • Create your html with the .selectpicker class.

    <select class="selectpicker">
      <option>Mustard</option>
      <option>Ketchup</option>
      <option>Relish</option>
    </select>
    

    Options can be passed via data attributes or JavaScript.

    $('.selectpicker').selectpicker({
      style: 'btn-info',
      size: 4
    });
    

    If you have not included libraries then include them all.

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/i18n/defaults-*.min.js"></script>