views:

53

answers:

2

So I have an element that has an onClick event thusly:

var foobar = $('element').addEvent('click', function() {
    // some code here
});

But I want to call the action from somewhere else in the script, would it be possible to do such a thing, i.e."

foobar.click

?

+4  A: 

You can fire events in mootools:

$('element').fireEvent('click');

http://mootools.net/docs/core/Element/Element.Event#Element:fireEvent

In addition you can pass in parameters or a delay, chain the event to other events, or bind another element or function with the event.

If you have more than one 'click' event on the element, it will fire all of them.

Check out the docs.

SamGoody
Found it just as you posted. Cheers!
Julian H. Lam
+1  A: 

Yes. From http://mootools.net/docs/core/Element/Element.Event#Element:fireEvent :

foobar.fireEvent('click');
qstarin