且构网

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

道场"装载" -message

更新时间:2023-02-17 08:37:20

你所描述的是什么假设道场本身已经加载的时候,该模式 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()$内C $ C>。

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.