Binding one function to handle multiple events
Reported by charlie | January 18th, 2010 @ 05:55 PM
This would be particularly useful when using doing mouseover OR focus, or mouseup OR mouseleave, attaching keyboard events etc.
And would make the code easier to manage, as something along the lines of:
var next;
// other code here
function exit() {
var nav = glow.dom.get("#nav-left", "#nav-right");
glow.events.addListener(nav, "mouseleave",
function() {
doSomething();
});
glow.events.addListener(nav, "mouseup",
function() {
doSomething();
});
function doSomething() {
clearInterval(next);
}
}
Could be reduced to something like:
var next;
// other code here
function exit() {
glow.events.addListener(
glow.dom.get("#nav-left", "#nav-right"),
("mouseleave", "mouseup"),
function() {
clearInterval(next);
});
}
No comments found
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A JavaScript Library