Reputation: 1521
I am using bootstrap select plugin, When the options at bottom of the select is selected the bootstrap select does not refresh the select properly(the previously selected options remains as selected as the boostrap select does not remove the selected class properly), Do I have to listen the change event on bootstrap select and refresh the options, This is not occurring while having lesser options, What mightbe the solution for this
$('.selectpicker').selectpicker({
});
Js fiddle :
https://jsfiddle.net/aarthi_101/79rz3j1w/18/,
I have posted an issue at github, https://github.com/snapappointments/bootstrap-select/issues/85
Upvotes: 3
Views: 4620
Reputation: 105
Just refresh when change the select and it'll work well. The code :
$('select').on('change',function(){
$(this).selectpicker('refresh');
});
Upvotes: 4
Reputation: 276
Try this fiddle: https://jsfiddle.net/h6dkgL35/
I added a script to remove the 'active' class from the previously selected option.
$('.dropdown-item').on('click', function() {
$('.dropdown-item').removeClass('active');
$(this).addClass('active');
});
I also added a style because the newly selected option had a blue background instead of purple.
Upvotes: 0