Why is jQuery running a newly delcared .click() in IE when it shouldnt?
I've run into this issue and I'm not sure why it's happening. I've created my own expander and collapser.
The expander is initially collapsed, and its onclick is initially set to call the showRushee() function. When it's clicked, it does what it needs to do, unbinds its .click() event, and rebinds the .click() to execute the hideRushee() function. The same goes for the hideRushee() function, just setting it back to showRushee(). Makes sense right?
Well, this all works perfectly... except for in IE. It doesn't work when clicking for the first time on the expander. Instead of working how it should, it ends up running the full loop and closing having everything collapsed. Clicking on the expander a second time has everything working perfectly and I'm at a stump.
I've run the debugger and here's the call stack in an unminified version of jQuery 1.4.2 (going from the first call up to my function).
- if ( !eventHandle ) {
elemData.handle = eventHandle = function() {
// Handle the second event of a trigger and when
// an event is called after a page has unloaded
return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
jQuery.event.handle.apply( eventHandle.elem, arguments ) :
undefined;
};
}
- var ret = handleObj.handler.apply( this, arguments );
- function hideRushee(...)... // Didn't include my function in this
Does anyone know why this is happening in IE?