For the below code, I am getting a dialog box message with the text
"callback not set by subclass" instead of "my subclass callback
function". Using JS 1.5, is there anyway I can enhance the below code
so that it works the way I want it too? I want to publish these
classes in a .js file and let the developer set myVar.callbackf ctn to
be whatever they want it to be for each class instance, and then I want
this.process() to call the callback function that the developer set for
each instance.
I basically want MySubClass() and MyBaseClass() to behave identically
for the users of the library: just two different class names for the
same functionality.
If the developer directly uses new MyBaseClass(), everything works
fine: the code calls the function that the developer assigns to
callbackfctn.
=====
function MySubClass()
{
}
MySubClass.prot otype = new MyBaseClass;
function MyBaseClass()
{
this.callbackfc tn = function () { alert("callback not set by
subclass"); };
this.process = function()
{
this.callbackfc tn(); // want this to call the function set by
the subclass
};
}
var myVar = new MySubClass();
myVar.callbackf ctn = function() { alert("my subclass callback
function"); };
myVar.process() ;
"callback not set by subclass" instead of "my subclass callback
function". Using JS 1.5, is there anyway I can enhance the below code
so that it works the way I want it too? I want to publish these
classes in a .js file and let the developer set myVar.callbackf ctn to
be whatever they want it to be for each class instance, and then I want
this.process() to call the callback function that the developer set for
each instance.
I basically want MySubClass() and MyBaseClass() to behave identically
for the users of the library: just two different class names for the
same functionality.
If the developer directly uses new MyBaseClass(), everything works
fine: the code calls the function that the developer assigns to
callbackfctn.
=====
function MySubClass()
{
}
MySubClass.prot otype = new MyBaseClass;
function MyBaseClass()
{
this.callbackfc tn = function () { alert("callback not set by
subclass"); };
this.process = function()
{
this.callbackfc tn(); // want this to call the function set by
the subclass
};
}
var myVar = new MySubClass();
myVar.callbackf ctn = function() { alert("my subclass callback
function"); };
myVar.process() ;
Comment