I am new to Javascript Object Oriented Programming. I need to write a JS class, which can be inherited. The complete class can be inherited. As well as whenever the document is ready, it gets called.
I am trying in this following way:
alert('reached');
var Hello = new VeerWidget();
function VeerWidget(){}
VeerWidget.prototype.constructor = function()
{
$(document).ready(function(){
alert('called');
});
}
I have the above code in xyz.js
What I am expecting is: as soon as the page loads, popup with reached is called followed by popup with called.
But this is not working. popup with reached is called. However called is not called.
However when I am trying this way:
alert('reached');
var Hello = new VeerWidget();
function VeerWidget()
{
$(document).ready(function(){
alert('called');
});
}
Everything goes fine. But I need to inherit VeerWidget. How to do this.?
Helloand then setting the constructor. First define everything you need to define on VeerWidget and then make instances