I’m attempting to implement the solution provided here, but apparently is conflicting with jquery as described in this ticket.
So far I dind’t find a solution, any ideas?
I want to implement the inheritance mechanism proposed by Shelby Moore
This may be the cause of the problem, extending the Object prototype:
Object.prototype.Inherits = function(parent)
{
if(arguments.length > 1)
{
parent.apply(this, Array.prototype.slice.call(arguments, 1));
}
else
{
parent.call(this);
}
}
EDIT 1: After extensive reading I adopted the following pattern:
NewFunction.prototype = Object.create(new FunctionToInheritFrom());
Extending the Object.prototype extends all Objects, so your if you modify the prototype of all Objects you can brake their desired behavior and that is why one should avoid to modify to Object prototype directly. It is better practice to extend custom functions prototypes, that ensures not to brake other prototypes, i.e. provided by frameworks like jQuery. Even Objects that represent DOMElements are modified what is a bad idea in general.
Nevertheless I would like to mention that Javascript itself does not define real Inheritance and trying to work around this leads to a lot of problems and makes it more difficult to develop. Inheritance in Javascript is prototype based Inheritance, which is different from real Inheritance, facing this fact and using Javascripts own methods for “something like inheritance” (i.e. described here) is straight forward and works very good.
For me, Javascript inheritance is more like merging object-members and a very good article about this is this one of douglas crockford, I think it is worth reading.