views:

305

answers:

1

Hi!

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?

A: 
jQuery.extend(Foo.prototype, proxied.prototype);

Or even:

Foo.prototype = proxied.prototype;
J-P