[Javascript] adding onclick event's with YUI
Matt Warden
mwarden at gmail.com
Wed Jul 18 12:40:12 CDT 2007
On 7/18/07, Matt McKeon <matt at mysticalmonkey.com> wrote:
> I'm using YUI to add onclick events to a list of links unobtrusively. I
> can do it if I manually set each one up, but if I do the same thing in a
> loop it doesn't quite work as expected.
You are right. This is a scope issue. Easiest way around it is to
assign the loop variable to a property of the relevant object.
myobj.foo = counter + "whatever";
function callback()
{
var importantVariable = this.foo;
}
--
Matt Warden
Cincinnati, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
More information about the Javascript
mailing list