Does anybody know of a method to trigger an event in Prototype, as you can with jQuery’s trigger function?
I have bound an event listener using the observe method, but I would also like to be able to fire the event programatically.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
event.simulate.jsfits your needs.I’ve used this several times and it works like a charm. It allows you to manually trigger native events, such as click or hover like so:
The great thing about this is that all attached event handlers will still be executed, just as if you would have clicked the element yourself.
For custom events you can use the standard prototype method
Event.fire().