且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在道场通用加载图标

更新时间:2023-11-21 11:26:40

您可以做到这一点通过 道场/话题 ,即 IO管道的主题,这是自道场1.4工作。

You can achieve this via dojo/topic, namely IO Pipeline Topics, which works since Dojo 1.4.

请参阅工作的例子在的jsfiddle: http://jsfiddle.net/phusick/cMHdt/

See working example at jsFiddle: http://jsfiddle.net/phusick/cMHdt/

首先,你必须全局启用IO管道主题,集 ioPublish:真正的 dojoConfig 之一, 数据道场-配置 djConfig (取决于您所使用的)。

First of all you have to globally enable IO Pipeline Topics, set ioPublish: true in one of dojoConfig, data-dojo-config or djConfig (depends on which you use).

然后 dojo.subscribe()来具体议题,如:

dojo.subscribe("/dojo/io/start", function(e) {
    dojo.style(throbberNode, "display", "block");
});

dojo.subscribe("/dojo/io/stop", function(e) {
    dojo.style(throbberNode, "display", "none");
});

可用主题根据Dojo文档是:

Available topics according to Dojo documentation are:

  • /体育馆/ IO /启动时,有没有突出的IO请求被发送出去,一个新的IO请求启动。没有参数​​传递这一主题。
  • /体育馆/ IO /发送每当一个新的IO请求,开始发送。它通过dojo.Deferred与话题的请求。
  • /体育馆/ IO /负载是每当一个IO请求加载成功发送。它传递的响应和dojo.Deferred与话题的请求。
  • /体育馆/ IO /错误是,每当一个IO请求误发送。它传递了错误的dojo.Deferred与话题的请求。
  • /体育馆/ IO /完成发送每当一个IO请求已经完成,无论是装载或示数。它传递了错误的dojo.Deferred与话题的请求。
  • /体育馆/ IO /停止时,所有未完成的IO请求完成后发送。没有参数​​传递这一主题。
  • /dojo/io/start is sent when there are no outstanding IO requests, and a new IO request is started. No arguments are passed with this topic.
  • /dojo/io/send is sent whenever a new IO request is started. It passes the dojo.Deferred for the request with the topic.
  • /dojo/io/load is sent whenever an IO request has loaded successfully. It passes the response and the dojo.Deferred for the request with the topic.
  • /dojo/io/error is sent whenever an IO request has errored. It passes the error and the dojo.Deferred for the request with the topic.
  • /dojo/io/done is sent whenever an IO request has completed, either by loading or by erroring. It passes the error and the dojo.Deferred for the request with the topic.
  • /dojo/io/stop is sent when all outstanding IO requests have finished. No arguments are passed with this topic.