1

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
  • Isn't it supposed to be return Bar(params); in your code? Commented Aug 16, 2010 at 11:32

1 Answer 1

2
jQuery.extend(Foo.prototype, proxied.prototype);

Or even:

Foo.prototype = proxied.prototype;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.