Wednesday, February 9, 2011

Showing a loader while Spry XMLDataset loads the data

i am using Spry (SpryData.js,xpath.js)

    var ds1 = new Spry.Data.XMLDataSet("_db/db.xml", "bildiriler/bildiri",{useCache:false});
 // load the xml tree

....

<!-- use it in a loop - 
 Sometimes the page use "ds1.loadData();" to refresh the data -->
 <div spry:region="ds1" spry:repeatchildren="ds1">
 <a href="#">{author}</a></div>

So how can i show a loader animation or "Loading text" while xml data is loading (it takes long time -about 2 sec from a slow CD-. My xml file is big 100KB )

  • I am not quite good at Spry, but can't you add a css background to the div placeholder (<div spry:region="ds1" ...) which will be shown at all time (and probably can be replaced through an observer that sets the background-image of the placeholder when the rows are loaded)...

  • Yes pretty good solution. But not exactly.

    Spry loads the data (very short) an dump them to spry:region (this takes long time) So the loader image appears in the first short time. And disappears quickly.

  • Yes. I found it (strangely, not from the docs of Spry on http://labs.adobe.com/technologies/spry) I found it from this example -> http://www.infoaccelerator.net/blog/archives.cfm/date/2006/7

    i put this line into the div tag (spry:region) :

    <p spry:state ="loading"> Loading ( text or an image ) </p>
    
  • <div align="center" spry:region="dsmain" spry:state="loading" >
    <img src="../icon/Loader/1.gif" />
    <br />please wait ...
    </div>   
    
    From loali

0 comments:

Post a Comment