Created
February 15, 2010 14:15
-
-
Save apipkin/304676 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
// where... | |
someFunc = function(e) { | |
// e has the event data | |
} | |
// I'm having a play with YUI 3 and came across an oddity. | |
Y.all('input').on('focus', someFunc); | |
// In the context of someFunc, 'this' is the set of inputs and | |
// not the specific input that gained the focus. | |
// Based on the documentation, this is the correct behaviour. | |
// I assume the way to work around this is: | |
Y.all('input').each(function () { | |
this.on('focus', someFunc); | |
} | |
// … but I wonder if there is a nicer approach out there. | |
// You describe your problem. Ask the world. Think of a | |
// slightly different search term. Then find the answer. | |
// Via http://developer.yahoo.com/yui/3/examples/node/nodelist.html | |
Y.all('input').each(function (o) { | |
o.on('focus', someFunc); | |
} | |
// if you want `this` in someFunc to be the element pass the element as context | |
Y.all('input').each(function (o) { | |
o.on('focus', someFunc, o); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment