function BaseController(el) {
var that = this;
this.defaultAction = function() {
alert('BaseController el val: ' + el); // el is not defined...
};
}
function StoryController(el) {
var that = this;
// call super constructor
BaseController.apply(that,arguments); // even though I am passing el it is not defined in the super class
this.defaultAction = function() {
alert('StoryController el val: ' + el); // el is defined
StoryController.prototype.defaultAction.apply(that);
};
}
StoryController.prototype = new BaseController(); // this is the problem, how can I do this without creating an instance, considering I can't pass the constructor arguments at this point?
StoryController.prototype.constructor = StoryController;
// -----------------------------------------------------------------
var story = new StoryController('one');
story.defaultAction();
What is the proper method here so that el will be defined in the super “class”.? I know I saw something on stack overflow a couple of days ago but can not seem to find it again.
admin: Something is up with the code tags, I have no idea why the system is double posting the code. Does HIGHLIGHT=JS not exists anymore? – That seemed not be working.