OK. I figured out where the flaw in my logic was.

I didn't realise that when you set a function/onXXXXX in the Options
it really adds them as an event to the object, so in effect I was just
adding additional events for the Request to perform without overriding
the earlier defined event.

I can use the same object now if I remove the events via removeEvents
('onComplete') and then set call setOptions with the one event I
really want to execute.


On Jan 12, 11:42 am, BB <[email protected]> wrote:
> Hi,
>
> I'm currently making Requests to a php page to retrieve some
> information from a database.
> At the moment, I have 4 Request objects created that all hit the same
> php page for data and this all works fine.
>
> But, is it possible to override the onComplete/onSuccess options so
> that I can use just the 1 Request object to replace the 4 I currently
> have? I'm currently setting the onComplete after the Request object
> has been created. For example:
>
> var ajax1 = new Request( {url:'/company_reqs.php'} );
>
> ...
> ...
> ...
> ...
> ajax1.setOptions( { onComplete:getSomeInfo } );
> ajax1.send({ data:{'req':'my_request', 'e':some_value,
> 'name':some_other_value } });
>
> and that works fine. But, if I later try to change the onComplete (I'm
> still hitting the same url for the request):
>
> ajax1.setOptions( { onComplete:getSomeDifferentInfo } );
> ajax1.send({ data:{'req':'my_alterrnative_request', 'b':x_value,
> 'c':y_value } });
>
> then when ajax1 completes, it calls 'getSomeInfo' (i.e. the original
> onComplete set on the Request object) and not the new onComplete I
> tried to set.
>
> I've had a search around here, Google and the mootools docs, but I
> can't find anything that says you can't do this (or even find posts
> from others asking the same thing). So, in a nutshell, is it possible
> to redefine
>
> I'm pretty new to mootools, so feel free to point out if I'm doing
> something dumb/obviously incorrect.
>
> Thanks v much.

Reply via email to