J'utilise Durandal 1.2, dans mon viewmodel j'ai fonction Activate:Durandal activer la fonction Code async
self.activate = function (data) {
function update(clienteId) {
self.Loading(true);
return $.when(
clienteRepository.ClienteCompact(clienteId),
clienteRepository.Prodotti(clienteId),
clienteRepository.Interventi(clienteId),
clienteRepository.Abbonamenti(clienteId)
).then(function (cliente, prodotti, interventi, abbonamenti) {
self.Cliente(cliente[0]).Prodotti(prodotti[0]).Interventi(interventi[0]).Abbonamenti(abbonamenti[0]);
self.Loading(false);
debugger;
});
};
var clienteId = data.splat[1];
if ($.isNumeric(clienteId)) {
return update();
} else {
return true;
}
};
et j'ai fonction beforeBind:
self.beforeBind = function() {
debugger;
};
le problème est que la fonction beforeBind est appelée avant que la requête ajax ne se termine, donc la vue est vide.
Quelque chose ne va pas?
Merci;)