Hi jon-2,
First, it's hard for me to give you advice here because I don't know what
your ultimate objective is, so instead I'll say this: Whenever you're
programming something that seems a bit hacky or convoluted, you are probably
going about it the wrong way. In this case, I guarantee you are trying to do
this the hard way.
First, when you use the Options class in your own classes,
options.onComplete is removed when you do this.setOptions(options), so this
statement won't work when called after you set the options. I'm guessing
you're doing this before that, though, or else you'd get an undefined error.
Secondly, MooTools offers you a way to add more than one function to an
event. Example:
var myReq = new Request({
onComplete: fn1
});
myReq.addEvent('complete', fn2);
//also, this works:
myReq.addEvent('onComplete', fn3);
There is no need to try and combine the functions yourself.
jon-2 wrote:
>
>
> I want to merge the onComplete callBack with another function before
> pass it off to an ajax call(eg. Request.HTML).
> I tried the following code, but it produced an infinite loop(halted
> after like 10 recursive calls to onComplete).
> I understand why, but is there a solution to simply create a function
> F that executes what's already in options.onComplete, then execute the
> second function, and then pass F as the onComplete callBack?
> thanks
>
> function mergeFunction(f1, f2){
> return function(){
> f1.attempt(arguments);
> f2.attempt(arguments);
> };
> }
> options.onComplete=mergeFunction(options.onComplete, function(){
> func2();
> });
>
>
-----
The MooTools Tutorial: http://www.mootorial.com www.mootorial.com
CNET Clientside: http://clientside.cnet.com clientside.cnet.com
--
View this message in context:
http://n2.nabble.com/merging-two-functions-tp1140856p1140908.html
Sent from the MooTools Users mailing list archive at Nabble.com.