Reputation: 11241
It seems that jQuery's trigger()
only runs event handlers that were bound with jQuery. I have some modules that use native browser event binding. Using the code from https://stackoverflow.com/a/2676527 works for me, but I'm wondering if there's something built in to jQuery that will do this?
Update from comments: apparently it works for click events on buttons. But not for change events on select boxes: http://jsfiddle.net/qxpXV/2/
For the record: hacking the other library to do its bindings with jQuery does make trigger()
work, but I don't really want to do that.
Upvotes: 6
Views: 941
Reputation: 24988
You can do this by manually firing/dispatching an event (depending on the browser, fireEvent
/dispatchEvent
) directly on the DOM element. Code from this answer will handle the event dispatching, you'll just need to execute it against a DOM element and not the jQuery wrapper.
Upvotes: 1