| (go back to full page)
includes are a simple way to do blending of HTML and Dojo components, though not as complex as the modification
syntax, includes provide a simpler mechanism to change the UI.
One use case for the include functionality is delayed loading of content until needed.
Take the example where you have a multiple screen application using a stack container. As a developer I would
want to delay load the content of the second and third screens until it is needed. This will decrease startup time
and increase perceived performance of the application.
<script type="text/javascript"> dojo.require("dijit.form.Button"); dojo.require("dijit.layout.StackContainer"); dojo.require("dijit.layout.ContentPane"); </script> <link rel="stylesheet" href="js/dijit/themes/tundra/tundra.css" type="text/css"> <link rel="stylesheet" type="text/css" href="js/dojox/grid/_grid/Grid.css"></link> <link rel="stylesheet" type="text/css" href="js/dojox/grid/_grid/tundraGrid.css"></link> <script> function displaySecondScreen(){ var stackLayout = dijit.byId('stackLayout'); var secondScreen = dijit.byId('secondScreen'); if (secondScreen==null){ dojoe.includeRequest({url:'js/dojoe/tests/_base/resources/secondScreen.html'}, "div[id='stackLayout']", "append"); secondScreen = dijit.byId('secondScreen'); } stackLayout.selectChild(secondScreen); } function displayThirdScreen(){ var stackLayout = dijit.byId('stackLayout'); var thirdScreen = dijit.byId('thirdScreen'); if (thirdScreen==null){ dojo.require("dojox.grid.Grid"); dojoe.includeRequest({url:'js/dojoe/tests/_base/resources/thirdScreen.html'}, "div[id='stackLayout']", "append"); thirdScreen = dijit.byId('thirdScreen'); } stackLayout.selectChild(thirdScreen); } </script> <div dojoType="dijit.form.Button" onclick="dijit.byId('stackLayout').selectChild(dijit.byId('firstScreen'))" label="First Screen"></div> <div dojoType="dijit.form.Button" onclick="displaySecondScreen()" label="Second Screen"></div> <div dojoType="dijit.form.Button" onclick="displayThirdScreen()" label="Third Screen"></div> <br/><br/> <div dojoType="dijit.layout.StackContainer" id="stackLayout" style="width:400px;height:300px;border:1px solid RGB(0,0,0)"> <div dojoType="dijit.layout.ContentPane" title="Welcome to my application" id="firstScreen"> <ul> <li>This is one Item in the list</li> <li>This is one Item in the list</li> <li>This is one Item in the list</li> <li>This is one Item in the list</li> <li>This is one Item in the list</li> </ul> </div> </div> |