jQuery event handler queue
Posted
by resopollution
on Stack Overflow
See other posts from Stack Overflow
or by resopollution
Published on 2010-05-28T21:54:32Z
Indexed on
2010/05/28
22:02 UTC
Read the original article
Hit count: 346
Overview of the problem
In jQuery, the order in which you bind a handler is the order in which they will be executed if you are binding to the same element.
For example:
$('#div1').bind('click',function(){
// code runs first
});
$('#div1').bind('click',function(){
// code runs second
});
But what if I want the 2nd bound code to run first?
.
My current solution
Currently, my solution is to modify the event queue:
$.data(domElement, 'events')['click'].unshift({
type : 'click',
guid : null,
namespace : "",
data : undefined,
handler: function() {
// code
}
});
.
Question
Is there anything potentially wrong with my solution?
Can I safely use null as a value for the guid?
Thanks in advance.
.
© Stack Overflow or respective owner