Twitter Bootstrap SelectPicker Onchange Function Not Being Called
So I have a simple select list
Solution 1:
This is because Selectpicker generates <ul>
and <li>
tags and keeps the <select>
and <option>
aside. It adds 'rel' attribute to each <li>
element for you to know which option is selected in relation to the selected <li>
.
Anyways, you should either use an official onChange event from the Selectpicker plugin, or do something like the following:
$('ul.dropdown-menu.selectpicker li').on('click', function () {
var selectedValue = $($('select.selectpicker option')[$(this).attr('rel')]).val();
});
Post a Comment for "Twitter Bootstrap SelectPicker Onchange Function Not Being Called"