Suppose I have a click event on a link/button/etc.
var myButton = Y.one('.button');
myButton.on('click', function() {
// code
});
There is something else happening on the page that I want to trigger a click event on this button. How would I do this?
I saw YUI3's fire() method, but it looked like that was designed for custom events. If I am supposed to use fire(), then will myButton.fire('click')
work?
(I'm looking for the equivalent of jQuery's .trigger() method, which works on DOM events or custom events.)
Do you really need to trigger the click event on the button? Take the HTML below
You can make use of the custom events to put the real logic somewhere central.
Fiddle: http://jsfiddle.net/WZZmR/
If you are looking for equivalent of trigger in yui3 you can try using the 'simulate'
For the above statement to work you will need to add "node-event-simulate" roll up in the use method.