English 中文(简体)
So how I can control the page contents loading sequence in dojo
原标题:
  • 时间:2009-11-20 01:16:37
  •  标签:
  • dojo
  • loading

I m using dojo for our UI s, and would like to load certain part of page contents in sequence. For example, for a certain stock, I d like to load stock general information, such as ticker, company name, key stats, etc. and a grid with the last 30 days open/close prices. Different contents will be fetched from the server separately. Now, I d like first load the grid so the user can have something to look at, then, say, start loading of key stats which is a large data set takes longer time to load. How do I do this. I tried: dojo.addOnLoad(function() {

startGrid(); //mock grid startup function which works fine getKeyStats(); //mock key stat getter function also works fine });

But dojo is loading getKeyStats(), then startGrid() here for some reason, and sequence doesn t seem be matter here. So how I can control the loading sequence at will? Thanks in advance!

David

最佳回答

The sequence doesn t matter because they are asynchronous requests; they appear in the same order as responses were received from the server, which is not necessarily the same order as they were called in.

To load them in the correct order, make your requests as normal. Add a callback for a successful response that places the response data into a shared bucket in any order. Once you have the proper number of responses (check it at the end of your callback), start inserting data into the page in any order you like.

问题回答

you may want to look at dojo.publish and use a pub sub pattern to loosely couple these events so that you can order them. Pub sub will allow you to make the request and listen for all topics to fire. With this you could call the request asynchronously and load the widgets in there respective place while styling them hidden and use the pub sub to make them visible based on a sequence of topic publications.





相关问题
Get Dojo Radio Button Value?

I have an HTML form using dojo and have the following code for a radio button selection choice: dojo.require("dijit.form.RadioButton"); <link href="http://ajax.googleapis.com/ajax/libs/dojo/1....

is it possible to know if a dijit is displayed or not?

i have two divs on a page. each has several dijits. i have atoggle that shows only one div or the other. when i submit the form, i only want to validate the dijits that are in the div that is ...

dijit BorderContainer auto-grow

Is there a way to have a dijit.layout.BorderContainer auto-grow in height? I ve tried setting min-height: 200px; height: auto;, but it won t scale. I ve tried looking at the API, but that thing is a ...

Dojo Tabs as Custom Widgets

I ve created a number of widgets that are loaded as tab panes in a tabcontainer. Everything seems to work well, except I m getting different results when using my custom widgets vs. creating ...

What happened to Dojo DOH?

The Dojo Toolkit used to come with a testing facility called "Doh". It was in the /utils directory. Now when you download dojo-release-1.3.2 the /utils directory is nowhere to be found. Is Doh dead ...

热门标签