I have something like that:
// original function
Foo = function(params) {
do foo...
}
Foo.prototype.alert = function() {
alert('foo');
}
Now i want to interfere:
Bar = Foo;
Foo = function(params) {
do bar...
return Foo(params);
}
Or the JQuery way:
(function() {
var proxied = Foo;
Foo = function() {
do bar...
return proxied.apply(this, arguments);
};
})();
The problem now is that Foo is missing all its prototype methods. Any idea how I could make this work?
1 Answer 1
jQuery.extend(Foo.prototype, proxied.prototype);
Or even:
Foo.prototype = proxied.prototype;
answered Jul 16, 2009 at 11:28
James
112k32 gold badges165 silver badges177 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
return Bar(params);in your code?