Created
September 28, 2010 19:03
-
-
Save sidnei/601575 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works. Logs 'click'. | |
YUI().use("event", "node", "node-event-simulate", function(Y){ | |
var node = Y.one(".item"); | |
node.on("foo|click", function() { | |
console.log("clicked"); | |
}); | |
node.simulate("click"); | |
node.detach("foo|click"); | |
node.simulate("click"); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Does not work. Logs 'click' x2. If called again, x4 and so on. | |
YUI().use("event", "node", "node-event-simulate", function(Y){ | |
var nodes = Y.all(".item"); | |
var node = Y.one(".item"); | |
nodes.on("foo|click", function() { | |
console.log("clicked"); | |
}); | |
node.simulate("click"); | |
nodes.detach("foo|click"); | |
node.simulate("click"); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works. Logs 'click' once. | |
YUI().use("event", "node", "node-event-simulate", function(Y){ | |
var nodes = Y.all(".item"); | |
var node = Y.one(".item"); | |
nodes.each(function(n) { | |
n.on("foo|click", function() { | |
console.log("clicked"); | |
}); | |
}); | |
node.simulate("click"); | |
nodes.each(function(n) { | |
n.detach("foo|click"); | |
}); | |
node.simulate("click"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment