Hey guys.
For Enumerable, according to API Docs I've found: If there is no
context argument, the iterator function will preserve the scope it
would have anyway.
I've came to that:
function Person(name)
{
this.name=name;
this.Check=Check;
}
function Check()
{
alert("Context is " + this); //Object - ok
$w("John Mike Mary Jane").each ( function (n) {
alert("each context is " + this); //Window - why?
if (n == this.name)
alert("We have same names!");
} /*, this*/ );
}
var mike = new Person("Mike");
mike.Check ();
I assumed that while I'm in Check function my context is mike
instance. But each() is invoked in Window context instead. I had to
manually add context (like you see commented /*, this*/). Is it a bug
according to API Docs : If there is no context argument, the iterator
function will preserve the scope it would have anyway?
Greetings,
Tomasz Kalkosiński
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---