Friday 12 January 2007
Dojo chaining effects and callback use
By Maxime Biais, Friday 12 January 2007 at 22:37 :: AJAX
Dojo is an opensource javascript library that help web developper to write browser side code. It provides widgets, effects, graphic renderers and also helpers to write AJAX enabled apps.
This is not an really an AJAX example, just a simple effect created in chaining two basic dojo effects. This is not the case here, but in my application loadHandler function is called when data arrive from the webserver.
var sentData;
function changeScore() {
dojo.byId("score").innerHTML = sentData[0];
}
function loadHandler(type, data, evt) {
sentData = data;
fo = dojo.lfx.html.fadeOut("loginButton", 750, 0, changeScore);
fi = dojo.lfx.html.fadeIn("loginButton", 750);
dojo.lfx.chain(fo, fi).play();
}
The last argument of dojo.lfx.html.fadeOut is the callback called when the effect have been totally played. In this case, the callback will be called after fo finish and just before fi begins.
You can try it here: http://www.biais.org/demo/dojo-chaining-effect.html



