Debian Codegraph @

dojox/mvc/tests/controllers/step2_test_mvc.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>Step 2 of tests for Controllers, uses a ModelRefController.</title>
6 <style type="text/css">
7 @import "../css/app-format.css";
8 @import "../../../../dijit/themes/claro/claro.css";
9 </style>
10 <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1,mvc:{debugBindings:1}" src="../../../../dojo/dojo.js"></script>
11 <script type="text/javascript">
12 var ctrl;
13
14 require([
15 'dojo/parser',
16 'dojo/ready',
17 'dojox/mvc/getStateful',
18 'dojox/mvc/ModelRefController',
19 'dojox/mvc/parserExtension',
20 'dijit/form/TextBox',
21 'dijit/form/Button',
22 'dojox/mvc/Group',
23 'dojox/mvc/Output'
24 ], function(parser, ready, getStateful, ModelRefController){
25
26 // Initial data
27 var data = {
28 "id" : "360324",
29 "FullName" : "Mr. John Doe",
30 "Email" : "[email protected]",
31 "AddressLine1" : "123 Valley Rd.",
32 "AddressLine2" : "",
33 "City" : "Cary",
34 "State" : "NC",
35 "Zip" : "27513"
36 };
37
38 transformAddress2Class = {
39 format: function(value){
40 if(value && value.trim().length > 0){
41 return "row" // if AddressLine2 is set return row for class
42 }
43 return "hiderow"; // if AddressLine2 is not set return hiderow for class
44 }
45
46 };
47
48 // To move from getStateful to ModelRefController, the only change other than the call to require and call new ModelRefController,
49 // is to change the binding on the groups to use ctrl instead of model.
50 //
51 // In this example a transform (transformAddress2Class) is used to hide the row for AddressLine2 if it is blank.
52 // 'dojox/mvc/parserExtension' is required for this since the row being hidden is not a widget.
53 // The class attribute is bound to AddressLine2 with a direction and a transform.
54 //
55 // The ModelRefController constructor sets model to the results of the getStateful call which will take json data and make it Stateful
56 ctrl = new ModelRefController({model: getStateful(data)});
57
58 parser.parse();
59 });
60 </script>
61 </head>
62 <body class="claro">
63 <script type="dojo/require">at: "dojox/mvc/at"</script>
64 <div id="wrapper">
65 <div id="main">
66 <div>
67 <h2>Step 2 of test for Controllers, uses a ModelRefController.</h2>
68 <h2>Enter Shipping Address</h2>
69 </div>
70 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at(ctrl,'model')">
71 <div class="fullrow">
72 <label class="cell" for="nameInput">Full Name:</label>
73 <input class="cell" id="nameInput" data-dojo-type="dijit/form/TextBox"
74 data-dojo-props="value: at('rel:', 'FullName')">
75 </div>
76 <div class="fullrow">
77 <label class="cell" for="AddressLine1Input">Address Line1:</label>
78 <input class="cell" id="AddressLine1Input" data-dojo-type="dijit/form/TextBox"
79 data-dojo-props="value: at('rel:', 'AddressLine1')">
80 </div>
81 <div class="fullrow">
82 <label class="cell" for="AddressLine2Input">Address Line2:</label>
83 <input class="cell" id="AddressLine2Input" data-dojo-type="dijit/form/TextBox"
84 data-dojo-props="value: at('rel:', 'AddressLine2')">
85 </div>
86 <div class="fullrow">
87 <label class="cell" for="cityInput">City:</label>
88 <input class="cell" id="cityInput" data-dojo-type="dijit/form/TextBox"
89 data-dojo-props="value: at('rel:', 'City')">
90 </div>
91 <div class="fullrow">
92 <label class="cell" for="stateInput">State:</label>
93 <input class="cell" id="stateInput" data-dojo-type="dijit/form/TextBox"
94 data-dojo-props="value: at('rel:', 'State')">
95 </div>
96 <div class="fullrow">
97 <label class="cell" for="zipInput">Zipcode:</label>
98 <input class="cell" id="zipInput" data-dojo-type="dijit/form/TextBox"
99 data-dojo-props="value: at('rel:', 'Zip')">
100 </div>
101 </div>
102 <br/>
103 <div>
104 <h2>Verify the shipping address</h2>
105 </div>
106 <div class="fullrow" data-dojo-type="dojox/mvc/Group" data-dojo-props="target: at(ctrl,'model')">
107 <div class="fullrow">
108 <div class="boldnamecell" data-dojo-type="dojox/mvc/Output"
109 data-dojo-props="value: at('rel:', 'FullName')"></div>
110 </div>
111 <div class="fullrow">
112 <div class="namecell" data-dojo-type="dojox/mvc/Output"
113 data-dojo-props="value: at('rel:', 'AddressLine1')"></div>
114 </div>
115 <div class="hiderow" data-mvc-bindings="class: at('rel:', 'AddressLine2').direction(at.from).transform(transformAddress2Class)">
116 <div class="namecell" data-dojo-type="dojox/mvc/Output"
117 data-dojo-props="value: at('rel:', 'AddressLine2')"></div>
118 </div>
119 <div class="fullrow">
120 <div class="namecell" data-dojo-type="dojox/mvc/Output"
121 data-dojo-props="value: at('rel:', 'City')">${this.value},</div>
122 <div class="namecell" data-dojo-type="dojox/mvc/Output"
123 data-dojo-props="value: at('rel:', 'State')"></div>
124 <div class="namecell" data-dojo-type="dojox/mvc/Output"
125 data-dojo-props="value: at('rel:', 'Zip')"></div>
126 </div>
127 </div>
128 </div>
129 </div>
130 </body>
131 </html>