Accessing this within a method in your class

15 views
Skip to first unread message

Zachary

unread,
Sep 14, 2011, 3:21:50 PM9/14/11
to Joose
methods : {
collect : function(req, callback) {
var mid = req.managedelementid;
// Collect

var library = this.library
console.log(this.library);
console.log("collect using library " + library );
//library.collect(req, callback);
}

when I print 'this' I get the global object and not the Joose object I
created...

Is this a know issue? Any idea on what I am doing wrong here?

Nickolay Platonov

unread,
Sep 15, 2011, 12:32:58 AM9/15/11
to joos...@googlegroups.com
How do you call this method?

Looks like you are doing something like:

var collect = myInstance.collect
collect()

should be:
collect.call(myInstance)


--
You received this message because you are subscribed to the Google Groups "Joose" group.
To post to this group, send email to joos...@googlegroups.com.
To unsubscribe from this group, send email to joose-js+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joose-js?hl=en.




--
Nickolay

Reply all
Reply to author
Forward
0 new messages