Passing constructor arguments between child and super "class" properly


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.

bump

This is the stack overflow thread I was referring to. However, the implementation shown will not work given the methods are not part of the functions prototype. therefore, I have no way to access the super method unless I make it a prototype. In which case I can’t have it access el unless I assign it as a property.

I’m starting to think this is not possible unless el is assigned as a property of the instance, huh…

Alright, I don’t think this is even possible from my research. I will just need to assign el to a publicly accessible property, which I guess is fine.