In selectize, I wont call event, but is it don't working
jquery event Working,
Selectize event don't working
Help please.
<div><select id='select'>
<option value="0">Item 0</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
$(function () {
$('select').on('change', function () {
alert("Original input event: Change");
});
$('select').selectize({
onChange: function () {
alert("Selectize event: Change");
}
});
// this triggers an the event
$('#select').trigger( "change" );
});
http://jsfiddle.net/6zyums3d/9/
$('select').selectize({
onInitialize: function() {
this.trigger('change', this.getValue(), true);
},
onChange: function(value, isOnInitialize) {
alert('Selectize changed: ' + value);
}
});
Make sure that you passed value parameter to the change callback. Otehrwise it would be undefined
This is what worked for me with respect to triggering a change event on the select element itself.
$('select').selectize({
onChange: function() {
this.$input[0].dispatchEvent(new Event("change"))
}
})
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