[Proto-Scripty] Re: scope of "this" in anonymous functions

2009-09-01 Thread Nightfly
Event.observe(window, 'load', function() { this.myField = new Field(); }.bind(myObject));// assuming myObject is of type MyClass On Aug 23, 6:16 am, JoJo wrote: > May I get some help with the actual coding? I tried the following and > myField is still null when used by other methods in the cl

[Proto-Scripty] Re: scope of "this" in anonymous functions

2009-08-23 Thread T.J. Crowder
Hi, > myMethod(). I suspect this has something to do with the "this" scope > in my anonymous function. It's true that `this` within the function will not be what it was outside the function unless you do something to make it so, and certainly that would need to be fixed if you were going to do

[Proto-Scripty] Re: scope of "this" in anonymous functions

2009-08-22 Thread JoJo
May I get some help with the actual coding? I tried the following and myField is still null when used by other methods in the class. Event.observe(window, 'load', function() { this.myField = new Field(); }.bind(MyClass)); On Aug 22, 7:42 pm, DJ Mangus wrote: > Everything in js is an object.

[Proto-Scripty] Re: scope of "this" in anonymous functions

2009-08-22 Thread DJ Mangus
Everything in js is an object. Even function literals. On 8/22/09, JoJo wrote: > > How do I use bind? Doesn't the bind function take an object as an > argument? I'm doing this stuff inside a class, not an object. > > On Aug 22, 6:15 pm, Gareth Evans wrote: >> Use bind (method on the function ob

[Proto-Scripty] Re: scope of "this" in anonymous functions

2009-08-22 Thread JoJo
How do I use bind? Doesn't the bind function take an object as an argument? I'm doing this stuff inside a class, not an object. On Aug 22, 6:15 pm, Gareth Evans wrote: > Use bind (method on the function object) > see the typewriter example i wrote for syntax > > On Sun, Aug 23, 2009 at 9:06 AM,

[Proto-Scripty] Re: scope of "this" in anonymous functions

2009-08-22 Thread Gareth Evans
Use bind (method on the function object) see the typewriter example i wrote for syntax On Sun, Aug 23, 2009 at 9:06 AM, Mojito wrote: > > MyClass = Class.create({ > initialize: function() { > this.myField = null; > Event.observe(window, 'load', function() { > this.myField = n