Before I click reset button I choose "Company" in Chosen (dropdown list). The event occurs normally after I click reset. I choose "Company" again but event change
in dropdownlist doesn't occur.
Could anyone tell me how to trigger the change event for dropdownlist after clicking reset button and then the same element?
The code I have so far:
$("#mainMenu").change(function(e){ e.preventDefault(); loadFirstManu(true); });
Code for the reset button:
$("#btn_reset").click(function() { CKEDITOR.instances.ckeditor.setData(''); $('.mchosen').each(function() { $(this).val('').trigger('liszt:updated'); $('#submenu').attr('disabled', 'disabled').html(''); $('#secondsubmenu').attr('disabled', 'disabled').html(''); $('#s-menu').removeClass('required').html(''); $('#secondsubmenu').removeClass('validate[required]'); $('#tabmenu').attr('disabled', 'disabled').html(''); $('#tab').removeClass('required').html(''); });
});
$(document). ready(function(){ $('#countrylist'). change(function(e){ // Your event handler }); // And now fire change event when the DOM is ready $('#countrylist'). trigger('change'); });
The trigger() method is a method in jQuery which is used to trigger a specified event handler on selected element. Syntax: $(selector).trigger(event, param1, param2) Note: Extra parameters can be passed in trigger() method. Example 1: This method triggered two methods to increase the value of method.
This is what i figured out:
$('#my-select').val(5).trigger("liszt:updated")
liszt:updated
is no longer working in new version of chosen instead use below as Alexandru Cojan's answer suggesting
trigger("chosen:updated");
for newer version of chosen the event is "chosen:updated"
$(selector).trigger("chosen:updated")
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