PDA

View Full Version : toggle button's event handler not called when toggle() called



gfrancis1@gmail.com
25 Jan 2014, 6:56 PM
In this fiddle I have two buttons A and B.
If you hit A, it is toggled 'on' and it's event-handler is called.
If you hit B, button A is toggled off but it's event handler is not called, even though 'SupressEvents' is 'false'.

http://jsfiddle.net/3TPYy/

How can I make it so that A's event handler is called when it is 'toggle'd programatically?

gfrancis1@gmail.com
27 Jan 2014, 1:30 AM
I have made a work-around by calling the buttons click handler after the toggle(), but I would have expected toggle() to work this way by itself

btn.toggle(false); // set toggle 'off'
btn.fireEvent('click', item); // fire event handler

skirtle
27 Jan 2014, 2:35 AM
The toggle method is only about a dozen lines long. It's pretty easy to see what's going on if you just look at the source code.

The event fired is called toggle and the handler is called toggleHandler.