I am using the bootstrap select plugin (http://silviomoreto.github.io/) and I am handling the change event "changed.bs.select" to capture any selection changes. As per the documentation at https://silviomoreto.github.io/bootstrap-select/options/, " this event fires after the select's value has been changed. It passes through event, clickedIndex, newValue, oldValue. "
I would like to understand what the newValue and oldValue represent exactly. Because it is always the case where the new value is true and the oldValue is false.
Here is a fiddle to illustrate my point.
https://jsfiddle.net/muojdbh9/
HTML
<select class="selectpicker">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
<div class="res">
Waiting for a change event
</div>
jQuery
$(".selectpicker").on('changed.bs.select', function (event, clickedIndex, newValue, oldValue) {
$("div.res").html("newValue: " + newValue + "<BR>oldValue: " + oldValue);
});
If you like to have expected behaviour simply change
that.$element.trigger('changed.bs.select', [clickedIndex, $option.prop('selected'), state]);
to
that.$element.trigger('changed.bs.select', [clickedIndex, $option.prop('value'), prevValue]);
in your bootstrap-select.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With