JavaScript Tutorial/Dojo toolkit/Stack Container — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:24, 26 мая 2010
Содержание
Create stack container programmatically
<html>
<head>
<link rel="StyleSheet" type="text/css" href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dijit.layout.StackContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dojo.parser");
dojo.require("dojo.Button");
function f(){
var container = new dijit.layout.StackContainer({}, "foo");
var leftChild = new dijit.layout.ContentPane({});
leftChild.domNode.innerHTML="page 1";
var rightChild = new dijit.layout.ContentPane({});
rightChild.domNode.innerHTML="page 2";
container.addChild(leftChild);
container.addChild(rightChild);
container.startup( );
dijit.byId("foo").forward( );
}
</script>
</head>
<body class="tundra" onload=f()>
<div id=foo></div>
</body>
</html>
Stack container with back and forward actions
<html>
<head>
<link rel="StyleSheet" type="text/css" href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dijit.layout.StackContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dojo.parser");
dojo.require("dojo.Button");
</script>
</head>
<body class="tundra">
<div id="stack" dojoType="dijit.layout.StackContainer" style="margin:5px; border:solid 1px;">
<div dojoType="dijit.layout.ContentPane">One</div>
<div dojoType="dijit.layout.ContentPane">Two</div>
<div dojoType="dijit.layout.ContentPane">Three</div>
<div dojoType="dijit.layout.ContentPane">Four</div>
</div>
<button dojoType="dijit.form.Button">Back
<script type="dojo/method" event="onClick" args="evt">dijit.byId("stack").back( );</script>
</button>
<button dojoType="dijit.form.Button">Next
<script type="dojo/method" event="onClick" args="evt">dijit.byId("stack").forward( );</script>
</button>
</body>
</html>
Use StackContainer and ContentPane
<html>
<head>
<link rel="StyleSheet" type="text/css" href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dijit.layout.StackContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dojo.parser");
dojo.require("dojo.Button");
</script>
</head>
<body class="tundra">
<div id="stack" dojoType="dijit.layout.StackContainer" style="margin:5px; border:solid 1px;">
<div dojoType="dijit.layout.ContentPane">One</div>
<div dojoType="dijit.layout.ContentPane">Two</div>
<div dojoType="dijit.layout.ContentPane">Three</div>
<div dojoType="dijit.layout.ContentPane">Four</div>
</div>
<button dojoType="dijit.form.Button">Back
<script type="dojo/method" event="onClick" args="evt">dijit.byId("stack").back( );</script>
</button>
<button dojoType="dijit.form.Button">Next
<script type="dojo/method" event="onClick" args="evt">dijit.byId("stack").forward( );</script>
</button>
</body>
</html>
Wizard based on stack container
<html>
<head>
<link rel="StyleSheet" type="text/css"
href="js/dojo/dijit/themes/tundra/tundra.css">
<script type="text/javascript">
var djConfig = {
baseScriptUri : "js/dojo/",
parseOnLoad : true
};
</script>
<script type="text/javascript" src="js/dojo/dojo/dojo.js"></script>
<script>
dojo.require("dojo.parser");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.StackContainer");
dojo.require("dijit.form.Button");
</script>
</head>
<body class="tundra">
<button id="previous" onClick="dijit.byId("mainTabContainer").back()">Previous</button>
<button id="next" onClick="dijit.byId("mainTabContainer").forward()">Next</button>
<div id="mainTabContainer" dojoType="dijit.layout.StackContainer">
<p id="Page1" dojoType="dijit.layout.ContentPane" label="Intro">Page First</p>
<p id="Page2" dojoType="dijit.layout.ContentPane">Page Second.</p>
<p id="Page3" dojoType="dijit.layout.ContentPane">Page Third.</p>
</div>
</body>
</html>