I have just converted an piece of code that was an object literal to a class and am having problems with the scope in a jQuery $.each()
loop.
Say I have a class...
var myClass = function(var1) {
this.var1 = var1;
}
myClass.prototype.myFuncion = function() {
var context = this;
$.each(this.var1, function() {
context.myOtherFunction()
//is there any way of accessing 'this' from here?
})
}
I want to know how to access the class context from within the each?
I know I can define a variable outside of the loop but is this the preferred method?