0

I have a website that has lots of prototype.js ajax calls and now we need a function called before each of them. Is there a way to add to the function without actually changing the prototype.js script? Basically we are looking for a way so we don't have to go and update every call.

For example:

OLD:
new Ajax.Request(SOMEURL);

NEW:
somefunction();
new Ajax.Request(SOMEURL);

Is there a way to create the same thing as the NEW, but within the Ajax.Request?

Thanks,

2
  • By "not overwriting" do you mean you don't want to edit the source, or do you neither want to patch the function somewhere else? Commented Nov 30, 2011 at 20:29
  • Yeah I don't want to edit the source as I don't want to have to always modify every update of prototype. What I would like is if I could somehow add/extend it in a separate js file. Commented Nov 30, 2011 at 20:36

1 Answer 1

1

Prototype provides Ajax.Responders so you can do this:

Ajax.Responders.register({
    onCreate: someFunction
});
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.