Hi!
I was able to "nest" callbacks using the addCallback method, but now I need to
pass the return value of two of those deferred calls to a third one and I am
not being able to do that. I'm only seeing the last return (i.e. the return
from the second deferred call).
I believe that if I could somehow "extend" the return of the second callback
with the return of the first one it would solve my problem (there's no
conflict of property names).
What I'm doing (from what I saw at the tests directory):
================================================================================
var entrada_resultados = function() {
var d = new Deferred();
d.addCallback(get_amostras_analises);
d.callback();
d.addCallback(get_analises_fator_correcao);
d.addCallbacks(monta_tabela_resultados, metadataFetchFailed);
};
================================================================================
All three callbacks are run, but "monta_tabela_resultados" just get the
results from "get_analises_fator_correcao". I tried returning an array from
"get_analises_fator_correcao" and accessing each element separately, but it
didn't work.
When I insert "log" calls, I get the following output:
================================================================================
INFO: First callback...
INFO: get_amostras_analises
INFO: get_amostras_analises - finished
INFO: Firing callbacks
INFO: Second callback...
INFO: Third callback...
INFO: get_analises_fator_correcao
INFO: get_analises_fator_correcao - finished
INFO: monta_tabela_resultados
INFO: Data: [object XMLHttpRequest],Deferred(3, unfired)
INFO: Payload: [object Object]
INFO: monta_tabela_resultados - finished
================================================================================
And the functions signatures and return values are:
================================================================================
var get_amostras_analises = function() {
...
return d;
};
var get_analises_fator_correcao = function (more_data) {
...
return [more_data, d];
};
var monta_tabela_resultados = function(dados, extras) {
log("monta_tabela_resultados");
log("Data:", dados.toString());
var payload = evalJSONRequest(dados[0]);
log("Payload:", payload);
...
};
================================================================================
Here "d" is an AJAX call and is receiving JSON results from a TurboGears
method.
The array above was my last attempt to get both results, but it seems that the
call didn't work :-(
If I try an "evalJSONRequest" for "dados[1]", then the script aborts and I get
no error message.
What should I do? Is it possible like this? Should I try using global
variables to solve that? I want the result of the first two callbacks on the
third one.
Thanks for any help,
--
Jorge Godoy <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" 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/mochikit
-~----------~----~----~----~------~----~------~--~---