views:

204

answers:

1

In jQuery, I've done stuff like this in the past:

$('#someCheckbox').click();

And everything works as if the user just clicked on the element normally. However the same doesn't work in MooTools:

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

The checkbox doesn't get checked, nor do any of the bound event handlers fire.

Is there a way to do this? I need the already bound "click" event handlers to fire, so just setting it's "checked" attribute isn't an option.

Thanks

+2  A: 

The click event should fire when fireEvent('click') is called. See http://mootools.net/shell/8bbgn/ for a demo I just set up.

The checkbox doesn't get checked, as expected. To do this, you must set the checked property to true:

$('someCheckbox').setProperty('checked', true);
Ronald
Hmm.. well that definitely proofs the concept. But for some reason it's not working in my code. The handlers just don't fire. I'll have to debug some more...
Infinity
Ok crap, between it not checking the box, and the event handler requiring the box to be checked to do anything, all lead me to believe this wasn't working as expected. But all good now thanks for double checking
Infinity