ajax - Generic Loading Icon in Dojo -
i'm giving maintenance application makes several ajax calls with:
dojo.xhrpost() , dojo.xhrget() and want add generic loading "icon + message" calls on system.. seance system find difficult , low maintainable add loadingfunction call load:function of xhr
so wander if there way add listener ajax calls on system everytime made call show loading...
i read can aspect in 1.7 application i'm working on dojo version of 1.6
so if know way show generic message ajax calls.. .
thanks in advice..
you can achieve via dojo/topic, namely io pipeline topics, works since dojo 1.4.
see working example @ jsfiddle: http://jsfiddle.net/phusick/cmhdt/
first of have globally enable io pipeline topics, set iopublish: true in 1 of dojoconfig, data-dojo-config or djconfig (depends on use).
then dojo.subscribe() specific topics, e.g.:
dojo.subscribe("/dojo/io/start", function(e) { dojo.style(throbbernode, "display", "block"); }); dojo.subscribe("/dojo/io/stop", function(e) { dojo.style(throbbernode, "display", "none"); }); available topics according dojo documentation are:
/dojo/io/startsent when there no outstanding io requests, , new io request started. no arguments passed topic./dojo/io/sendsent whenever new io request started. passes dojo.deferred request topic./dojo/io/loadsent whenever io request has loaded successfully. passes response , dojo.deferred request topic./dojo/io/errorsent whenever io request has errored. passes error , dojo.deferred request topic./dojo/io/donesent whenever io request has completed, either loading or erroring. passes error , dojo.deferred request topic./dojo/io/stopsent when outstanding io requests have finished. no arguments passed topic.
Comments
Post a Comment