I am experimenting with "kendo.Class.extend()".
When I inherit a new class from a base class, how can i call the base class constructor from within the derived class constructor?
The below didn't work for me.
var ClsPerson = kendo.Class.extend(
{
FirstName:"<none>", LastName: "<none>", Married: false,
Display: function() { alert("I am " + this.FirstName + " " + this.LastName); },
init: function(FirstName, LastName)
{
if (FirstName) this.FirstName = FirstName;
if (LastName) this.LastName = LastName;
}
});
var ClsParent = ClsPerson.extend(
{
SpouseName: "<none>",
init: function(FirstName, LastName, SpouseName)
{
//if (FirstName) this.FirstName = FirstName;
//if (LastName) this.LastName = LastName;
ClsPerson(FirstName, LastName);
if (SpouseName) this.SpouseName = SpouseName;
}
});
var Parent1 = new ClsParent("Sakthivel", "S", "Sangitha S");
Parent1.Display();
alert(Parent1.SpouseName);
I tried calling the base class constructor like "ClsPerson(FirstName, LastName); ", but didn't get the desired results.
When I inherit a new class from a base class, how can i call the base class constructor from within the derived class constructor?
The below didn't work for me.
var ClsPerson = kendo.Class.extend(
{
FirstName:"<none>", LastName: "<none>", Married: false,
Display: function() { alert("I am " + this.FirstName + " " + this.LastName); },
init: function(FirstName, LastName)
{
if (FirstName) this.FirstName = FirstName;
if (LastName) this.LastName = LastName;
}
});
var ClsParent = ClsPerson.extend(
{
SpouseName: "<none>",
init: function(FirstName, LastName, SpouseName)
{
//if (FirstName) this.FirstName = FirstName;
//if (LastName) this.LastName = LastName;
ClsPerson(FirstName, LastName);
if (SpouseName) this.SpouseName = SpouseName;
}
});
var Parent1 = new ClsParent("Sakthivel", "S", "Sangitha S");
Parent1.Display();
alert(Parent1.SpouseName);
I tried calling the base class constructor like "ClsPerson(FirstName, LastName); ", but didn't get the desired results.