Hi Mert,
You can create a factory function for requests that inserts your
handler, something like this:
* * * *
function specialSuccessStuff(transport)
{
// ...whatever your special onSuccess stuff is...
}
function makeRequest(url, options) {
var orig;
orig = options.onSuccess;
if (orig) {
options.onSuccess = function(transport) {
specialSuccessStuff(transport);
orig(transport);
};
} else {
options.onSuccess = specialSuccessStuff;
}
return new Ajax.Request(url, options);
}
* * * *
...then use makeRequest rather than new Ajax.Request for your actual
requests.
Or here's another way using Function.wrap[1]:
* * * *
function onSuccessWrapper(orig, transport)
{
// ...whatever your special onSuccess stuff is...
// Chain to original onSuccess handler
orig(transport);
}
function makeRequest(url, options) {
options.onSuccess = (options.onSuccess ||
Prototype.emptyFunction).wrap(onSuccessWrapper);
return new Ajax.Request(url, options);
}
* * * *
[1] http://prototypejs.org/api/function/wrap
HTH,
--
T.J. Crowder
tj / crowder software / com
On Nov 13, 9:30 am, matte <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have an application that uses Ajax.Request and its onSuccess event
> handler in lots of places.
>
> I need to call a function (that will check the response) before all
> these onSuccess events fired. I tried using Ajax.Responders.register
> with onComplete event but it fires after Ajax.Request's onSuccess
> event. Any suggestions?
>
> Thanks,
> Mert.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---