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/start sent when there no outstanding io requests, , new io request started. no arguments passed topic.
  • /dojo/io/send sent whenever new io request started. passes dojo.deferred request topic.
  • /dojo/io/load sent whenever io request has loaded successfully. passes response , dojo.deferred request topic.
  • /dojo/io/error sent whenever io request has errored. passes error , dojo.deferred request topic.
  • /dojo/io/done sent whenever io request has completed, either loading or erroring. passes error , dojo.deferred request topic.
  • /dojo/io/stop sent when outstanding io requests have finished. no arguments passed topic.

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -