I have a problem that I can\'t work around.
The context is: I want to have an inheritance chain, and a method of objects that belong to this inheritance has to be a
The first problem in your jsfiddle is that self is a local variable for Constructor and it is not available outside of the function. What you think about the following code:
var Constructor = function(name, value) {
var self = this;
self.name = name;
self.value = value;
self.someHandler = function(e) {
e.target.innerHTML = self.name + self.value; // self undefined
}
return self;
};
var myObject = Constructor('myName', 'myValue');
document.getElementById('myDiv').onclick = myObject.someHandler;
JsFiddle -> http://jsfiddle.net/ZcG3J/4/
Is it structured as you want?