Could anyone explain to me in what situations 'this' should be bound
and perhaps provide a few examples? I keep running into problems in
writing classes and I think that my lack of understanding of when and
how to use it is one of the major difficulties. I've looked at the
documentation in the mootorial and in the docs section, but the
explanations on binding are cursory at best. Any help would really be
appreciated. Thanks.
> Could anyone explain to me in what situations 'this' should be bound
> and perhaps provide a few examples? I keep running into problems in
> writing classes and I think that my lack of understanding of when and
> how to use it is one of the major difficulties. I've looked at the
> documentation in the mootorial and in the docs section, but the
> explanations on binding are cursory at best. Any help would really be
> appreciated. Thanks.
> In this case, newTween is the tween object and newTweenSet is the
> function.
> Now, inside the function newTweenSet, using "this" will refer to
> newTween, letting you write something like this:
> var newTweenSet = function() {
> this.start('width', '300px');
> }
> Hope this answers your question.
> On Aug 26, 1:51 pm, VirtuosiMedia <cont...@virtuosimedia.com> wrote:
> > Could anyone explain to me in what situations 'this' should be bound
> > and perhaps provide a few examples? I keep running into problems in
> > writing classes and I think that my lack of understanding of when and
> > how to use it is one of the major difficulties. I've looked at the
> > documentation in the mootorial and in the docs section, but the
> > explanations on binding are cursory at best. Any help would really be
> > appreciated. Thanks.
just a word because i think the question could concern the bind usage
inside a class
a little example, a very, very useful class :)))
#############"
var toto = new Class ({
- this.alternateMessage is now changed for the whole class, not only
inside the fucntion as this refers to the class
- without binding the click function with .bind(this) the result would
be "this.alternateMessage has no properties", "this.aMethod() is not a
function"
binding the function to the class (this) allows it to use any method
or this.var set inside it
> just a word because i think the question could concern the bind usage
> inside a class
> a little example, a very, very useful class :)))
> #############"
> var toto = new Class ({
> - this.alternateMessage is now changed for the whole class, not only
> inside the fucntion as this refers to the class
> - without binding the click function with .bind(this) the result would
> be "this.alternateMessage has no properties", "this.aMethod() is not a
> function"
> binding the function to the class (this) allows it to use any method
> or this.var set inside it