Debian Codegraph @

dojox/mvc/tests/docExamples/groupDeclarativeExample1.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html >
3 <head>
4
5 <style type="text/css">
6 @import "../../../../dijit/themes/claro/claro.css";
7 </style>
8 <style type="text/css">.row { width: 500px; display: inline-block; margin: 5px; }
9 .cell { width: 20%; display:inline-block; }</style>
10 <script src="../../../../dojo/dojo.js" data-dojo-config='parseOnLoad: true, mvc: {debugBindings: true}'></script><script>var searchRecords;
11
12 require([
13 'dojo/parser',
14 'dojo/ready',
15 'dojox/mvc/getStateful',
16 'dijit/form/TextBox',
17 'dijit/form/Button',
18 'dojox/mvc/Group',
19 'dojox/mvc/Output'
20 ], function(parser, ready, getStateful){
21
22 // Initial data
23 var order = {
24 "Serial" : "360324",
25 "First" : "John",
26 "Last" : "Doe",
27 "Email" : "[email protected]",
28 "ShipTo" : {
29 "Street" : "123 Valley Rd",
30 "City" : "Katonah",
31 "State" : "NY",
32 "Zip" : "10536"
33 },
34 "BillTo" : {
35 "Street" : "17 Skyline Dr",
36 "City" : "Hawthorne",
37 "State" : "NY",
38 "Zip" : "10532"
39 }
40 };
41 // The getStateful call will take json data and create make it Stateful
42 model = getStateful(order);
43 // the model created above is initialized with
44 // model.First set to "John", model.Last set to "Doe" and model.Email set to "[email protected]"
45
46 });
47
48 function setRef(id, model, attr) {
49 require([
50 "dijit/registry",
51 "dojox/mvc/at"
52 ], function(registry, at){
53 var widget = registry.byId(id);
54 widget.set("target", model[attr]);
55 });
56 };</script>
57 </head>
58 <body class="claro">
59 <script type="dojo/require">at: "dojox/mvc/at"</script>
60 <div id="main">
61 <div id="leftNav"></div>
62 <div id="mainContent">
63 <!--
64 The group container denotes some logical grouping of widgets and also serves
65 to establish a parent data binding context for its children.
66 The target attribute for the outermost container obtains the binding from the
67 "page scope" itself.
68 -->
69 <!--
70 For convenience, the widget hierarchy matches the data hierarchy
71 (see JSON literal above).
72 In this implementation, the child attributes are simple property names
73 of the parent binding context.
74 -->
75 <div class="row" id="addrGroup" data-dojo-type="dojox/mvc/Group"
76 data-dojo-props="target: model.ShipTo">
77 <div class="row">
78 <label class="cell" for="streetInput">Street:</label>
79 <input class="cell" id="streetInput" data-dojo-type="dijit/form/TextBox"
80 data-dojo-props="value: at('rel:', 'Street')">
81 </div>
82 <div class="row">
83 <label class="cell" for="cityInput">City:</label>
84 <input class="cell" id="cityInput" data-dojo-type="dijit/form/TextBox"
85 data-dojo-props="value: at('rel:', 'City')">
86 </div>
87 <div class="row">
88 <label class="cell" for="stateInput">State:</label>
89 <input class="cell" id="stateInput" data-dojo-type="dijit/form/TextBox"
90 data-dojo-props="value: at('rel:', 'State')">
91 </div>
92 <div class="row">
93 <label class="cell" for="zipInput">Zipcode:</label>
94 <input class="cell" id="zipInput" data-dojo-type="dijit/form/TextBox"
95 data-dojo-props="value: at('rel:', 'Zip')">
96 </div>
97 </div>
98 <br/>
99 Choose:
100 <button id="shipto" type="button" data-dojo-type="dijit/form/Button"
101 data-dojo-props="onClick: function(){setRef('addrGroup', model, 'ShipTo');}">Ship To</button>
102 <button id="billto" type="button" data-dojo-type="dijit/form/Button"
103 data-dojo-props="onClick: function(){setRef('addrGroup', model, 'BillTo');}">Bill To</button>
104 <br/>
105 <br/>
106 </div></div>
107 </body>
108 </html>