Closed demianturner closed 11 years ago
[jcasanova] Hey,
Of course that's a good idea, inheritance is missing in javascript. We provide the Prototype vendor library cause it's often used by developers but our aim is not to impose nor maintain any javascript library. So i would recommend you add this method anywhere else in a js file and include this file in the conf[site][globalJavascriptFiles] so you have it loaded on any page. You could also document this on the wiki, I'm sure it could help a lot of people.
Cheers,
Julien
Taken from:
http://www.someelement.com/2007/03/multiple-inheritance-with-prototypejs.html
With this function it is possible to subclass in Javascript using the Prototype library. Why it's needed is explained in the link above. I use this function to subclass a base modalDialog class for example. Using extend will not work, cause it will always call the constructor of the base class.
Example:
{{{ sglNavigation2NodeEditDialog = Class.create(); Object.inherit(sglNavigation2NodeEditDialog, sglModalDialog); Object.extend(sglNavigation2NodeEditDialog.prototype, }}}
In the constructor we do then:
{{{ sglNavigation2NodeEditDialog.base.call(this, data); }}}