Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap-select does not proxies click event

I had select element:

  <select id='selectBox'>
    <option>Mustard</option>
    <option>Ketchup</option>
    <option>Relish</option>
  </select>

and set click event via jquery:

$('#selectBox option').click(function(){
.....
});

after using http://silviomoreto.github.io/bootstrap-select/ :

  <select id='selectBox' class="selectpicker" multiple="" data-selected-text-format="count">
    <option>Mustard</option>
    <option>Ketchup</option>
    <option>Relish</option>
  </select>

I got nice multiply dropdown and all work fine except that when I click on menu item (select or delestct it) nothing happends.

Why not click event proxies from my original (which was hided) option element to the new created element 'ul.dropdown-menu li a' ? How can I fix it?

like image 720
gilnator Avatar asked Sep 06 '13 12:09

gilnator


1 Answers

Change you code to:

$('#selectBox').on('change', function(){
    .....
});

this must work;

like image 131
anacarolinats Avatar answered Oct 31 '22 09:10

anacarolinats