John Resig’s Simple Javascript Inheritance: http://ejohn.org/blog/simple-javascript-inheritance/
I tried to do such thing:
var SomeClass = Class.extend({
init: function() {
var someFunction = function() {
alert(this.someVariable);
};
someFunction(); // should alert "someString"
},
someVariable: "SomeString"
});
var someClass = new SomeClass();
This should alert "someString", but it doesn't because inside the closure function someFunction, the value of this doesn't refers to the class, it is changed. That makes me unable to get access to the properties and functions of the class inside a closure function.
Any suggestions?