Debian Codegraph @

dojox/mvc/tests/doh/doh_new-mvc_input-output-simple.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>Simple Input-Output Data Binding Example</title>
6 <style type="text/css">
7 @import "../css/app-format.css";
8 @import "../../../../dijit/themes/claro/claro.css";
9 </style>
10
11 <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1, mvc: {debugBindings: 1}" src="../../../../dojo/dojo.js"></script>
12 <script type="text/javascript">
13 var model;
14
15 require([
16 "doh/runner",
17 "dojo/dom",
18 "dojo/parser",
19 "dojo/when",
20 "dijit/registry",
21 "dojox/mvc/getStateful",
22 "dijit/form/TextBox",
23 "dijit/form/Button",
24 "dojox/mvc/Group",
25 "dojox/mvc/Output"
26 ], function(doh, ddom, parser, when, registry, getStateful){
27 // The dojox.mvc.StatefulModel class creates a data model instance
28 // where each leaf within the data model is decorated with dojo.Stateful
29 // properties that widgets can bind to and watch for their changes.
30 //model = mvc.newStatefulModel({data :{"First": "John", "Last": "Doe", "Email": "[email protected]"}});
31 model = getStateful({"First": "John", "Last": "Doe", "Email": "[email protected]"});
32 // the StatefulModel created above is initialized with
33 // model.First set to "John", model.Last set to "Doe" and model.Email set to "[email protected]"
34 when(parser.parse(), function(){
35 doh.register("Synchronize text box and label", [{
36 name: "Check first value",
37 runTest: function(){
38 doh.is("John", registry.byId("firstnameInput").get("value"), "First should reflect initial data");
39 doh.is("Doe", registry.byId("lastnameInput").get("value"), "Last should reflect initial data");
40 doh.is("[email protected]", registry.byId("emailInput").get("value"), "Email should reflect initial data");
41 doh.t(/\s*\(first name is: John\)\s*/, registry.byId("firstnameOut").innerHTML, "First should reflect initial data");
42 doh.t(/\s*\(last name is: Doe\)\s*/, registry.byId("lastnameOut").innerHTML, "Last should reflect initial data");
43 doh.t(/\s*\(email is: Doe\)\s*/, registry.byId("emailOut").innerHTML, "Email should reflect initial data");
44 }
45 }, {
46 name: "Check value sync",
47 runTest: function(){
48 model.set("First", "JohnJohn");
49 doh.t(/\s*\(first name is: JohnJohn\)\s*/, registry.byId("firstnameOut").innerHTML, "First should reflect the change");
50 }
51 }, {
52 name: "Check model reset",
53 setUp: function(){
54 model.set({"First": "John", "Last": "Doe", "Email": "[email protected]"});
55
56 //model.reset();
57 },
58 runTest: function(){
59 doh.is("John", registry.byId("firstnameInput").get("value"), "First should reflect initial data");
60 doh.is("Doe", registry.byId("lastnameInput").get("value"), "Last should reflect initial data");
61 doh.is("[email protected]", registry.byId("emailInput").get("value"), "Email should reflect initial data");
62 doh.t(/\s*\(first name is: John\)\s*/, registry.byId("firstnameOut").innerHTML, "First should reflect initial data");
63 doh.t(/\s*\(last name is: Doe\)\s*/, registry.byId("lastnameOut").innerHTML, "Last should reflect initial data");
64 doh.t(/\s*\(email is: Doe\)\s*/, registry.byId("emailOut").innerHTML, "Email should reflect initial data");
65 }
66 }]);
67
68 doh.run();
69 });
70 });
71 </script>
72 </head>
73 <body class="claro">
74 <script type="dojo/require">at: "dojox/mvc/at"</script>
75 <div id="wrapper">
76 <div id="header">
77 <div id="navigation"></div>
78 <div id="headerInsert">
79 <h1>Input Output Sync</h1>
80 <h2>Data Binding Example</h2>
81 </div>
82 </div>
83 <div id="main">
84 <div id="leftNav"></div>
85 <div id="mainContent">
86 <div class="row">
87 <label class="cell" for="firstnameInput">First:</label>
88 <input class="cell" id="firstnameInput" data-dojo-type="dijit.form.TextBox"
89 data-dojo-props="value: at(model, 'First')"></input>
90 <!-- Content in output below will always be in sync with value of textbox above -->
91 <span id="firstnameOut" data-dojo-type="dojox.mvc.Output"
92 data-dojo-props="value: at(model, 'First')">
93 (first name is: ${this.value})
94 </span>
95 </div>
96 <div class="row">
97 <label class="cell" for="lastnameInput">Last:</label>
98 <input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox"
99 data-dojo-props="value: at(model, 'Last')"></input>
100 <span id="lastnameOut" data-dojo-type="dojox.mvc.Output"
101 data-dojo-props="value: at(model, 'Last')">
102 (last name is: ${this.value})
103 </span>
104 </div>
105 <div class="row">
106 <label class="cell" for="emailInput">Email:</label>
107 <input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox"
108 data-dojo-props="value: at(model, 'Email')"></input>
109 <span id="emailOut" data-dojo-type="dojox.mvc.Output"
110 data-dojo-props="value: at(model, 'Email')">
111 (email is: ${this.value})
112 </span>
113 </div>
114 </div>
115 </div>
116 </div>
117 </body>
118 </html>