道场"装载" -message [英] Dojo "loading"-message

查看:121
本文介绍了道场"装载" -message的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的道场,所以我需要一点点帮助。

I'm new to Dojo, so I need a little help.

我的一些环节需要一段时间(当用户点击,它需要几秒钟的页面开始加载之前),我想补充一个装-message。

Some of my links takes a while (when the user clicks, it takes several seconds before the page starts loading), and I'd like to add a "loading"-message.

我能做到这一点的老时尚之路,但我想学新的,更简单,更智能的Dojo的方式。

I can do it the "old fashion way", but I want to learn the new, easier, smarter Dojo-way.

究竟它是如何工作并不重要,现在,但我想是这样的:

Exactly how it works is not important right now, but I imagine something like this:

一个矩形出现在浏览器窗口的中间。 (该文件没有中间)。它有一个GIF动画,而像请稍候...的消息。

A rectangle appears in the middle of the browser-windows. (Not the middle of the document.) It has an animated gif, and a message like "Please wait...".

所有其他元素都禁用,也许淡出了一下。也许一个大的白色50%透明度的矩形,其中的加载 - 消息和文档的其余部分之间。

All other elements are disabled, maybe "faded out" a bit. Maybe a big white 50% transparent rectangle, which sits between the "loading"-message and the rest of the document.

推荐答案

你所描述的是什么假设道场本身已经加载的时候,该模式 dijit.Dialog 出现的加载消息。

What you are describing assumes that dojo itself has already been loaded by the time that the modal dijit.Dialog appears with the loading message.

现在,通常情况下,道场启动你的页面完全加载执行一次,你通常把你的道场code通过为参数匿名函数dojo.addOnLoad()

Now, normally, dojo starts executing once your page is fully loaded, and you would normally put your dojo code inside an anonymous function passed as parameter of dojo.addOnLoad().

这引起该页面的其余部分(你打电话给你的链接)将不得不通过AJAX(使用加载,例如, dijit.layout.ContentPane )。这样一来,道场可以执行下载内容之前,并能更早出现在等待的消息。

That entails that the remaining part of your page (what you call your "links") will have to be loaded through ajax (using, for instance, dijit.layout.ContentPane). That way, dojo can execute before the content is downloaded, and your "waiting" message can appear earlier.

这可能是这样的:

<html>

<head>
<link rel="stylesheet" href="/dojo/dijit/themes/tundra/tundra.css" type="text/css" media="screen" />
<script type="text/javascript" src="/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
/* make sure that you shrinksafe together your libraries and dojo's for faster loading... */
<script type="text/javascript" src="/dojo/yourOwnDojoCompressedScripts.js"></script>
<script type="text/javascript">
   var dialog;
   dojo.addOnLoad(function(){
      dojo.require("dijit.layout.ContentPane");
      dojo.require("dijit.Dialog");
      dialog = new dijit.Dialog();
      dialog.setContent("<p>This page will be available in a tick!</p>");
      dialog.show();
   });
</script>
</head>

<body class="tundra">
   <div id="delayedContent" 
        dojoType="dijit.layout.ContentPane" 
        href="/myContentUrl"
        onLoad="dialog.hide()">
   </div>
</body>

</html>

在该计划唯一的缺陷是道场本身:期待你的 shrinksafed 的库重量超过90K(可能高达300K,这取决于你有多少东西摆在那里)。连接速度慢,仍需要时间来下载一个显着的量。这就是说,我们在谈论一个的静态的90K ---相同的用户会下载它只有一次每个会话,以及较少甚至比,如果你花时间来设置相应的缓存/到期报头当这些静态文件服务。

The only flaw in that plan is dojo itself: expect your shrinksafed library to weigh over 90K (possibly up to 300K, depending on how much stuff you put in there). On a slow connection, that still takes a noticeable amount of time to download. That said, we're talking of a static 90K --- the same user will download it only once per session, and even less often than that if you take the time to set appropriate cache/expire headers when those static files are served.

这篇关于道场&QUOT;装载&QUOT; -message的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆