Debian Codegraph @

dojox/mvc/tests/WidgetList_tests/test_mobile-list-single-sel-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 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
6 <meta name="apple-mobile-web-app-capable" content="yes"/>
7 <title>MVC Repeat with Selectable RoundRectList - Single Select</title>
8
9 <script type="text/javascript" src="../../../../dojox/mobile/deviceTheme.js" data-dojo-config="mblThemeFiles: ['base']"></script>
10
11 <!-- required: dojo.js -->
12 <script type="text/javascript" src="../../../../dojo/dojo.js"
13 data-dojo-config="isDebug: true, async: true, parseOnLoad: false, mvc: {debugBindings: true}"></script>
14
15 <script type="text/javascript">
16 require([
17 "dojo/_base/lang",
18 "dijit/registry",
19 //"dojox/mobile/parser",
20 "dojo/parser",
21 "dojo/store/Memory",
22 "dojo/ready",
23 "dojo/when",
24 "dojox/mvc/getStateful",
25 "dojox/mvc/Group",
26 "dojox/mvc/Repeat",
27 "dojox/mvc/Templated",
28 "dojox/mvc/WidgetList",
29 "dojox/mvc/Output",
30 "dojox/mobile",
31 "dojox/mobile/Button",
32 "dojox/mobile/TextBox",
33 "dojox/mobile/CheckBox",
34 "dojox/mobile/deviceTheme"
35 ], function(lang, registry, parser, MemoryStore, ready, when, getStateful){
36 var search_results_init1 =
37 [{
38 "Query" : "Engineers1",
39 "Results" : [
40 {
41 "First" : "Anne1",
42 "Last" : "Ackerman1",
43 "Checked" : true
44 },
45 {
46 "First" : "Ben1",
47 "Last" : "Beckham1",
48 "Checked" : false
49 },
50 {
51 "First" : "Chad1",
52 "Last" : "Chapman1",
53 "Checked" : false
54 }
55 ]
56 }];
57
58 var search_results_init2 =
59 [{
60 "Query" : "Engineers1",
61 "Results" : [
62 {
63 "First" : "Anne2",
64 "Last" : "Ackerman2",
65 "Checked" : false
66 },
67 {
68 "First" : "Ben2",
69 "Last" : "Beckham2",
70 "Checked" : true
71 },
72 {
73 "First" : "Chad2",
74 "Last" : "Chapman2",
75 "Checked" : false
76 }
77 ]
78 }];
79 var memStore1 = new MemoryStore({data : search_results_init1});
80 //model1 = mvc.newStatefulModel({ store : memStore1 })[0];
81
82 when(memStore1.query(), function(data){
83 model1 = getStateful(data)[0];
84 model1Orig = lang.clone(model1);
85 //if(model1 && model2 && model3){ runTests(); }
86 });
87
88
89 var memStore2 = new MemoryStore({data : search_results_init2});
90 //model2 = mvc.newStatefulModel({ store : memStore2 })[0];
91 when(memStore2.query(), function(data){
92 model2 = getStateful(data)[0];
93 model2Orig = lang.clone(model2);
94 //if(model1 && model2 && model3){ runTests(); }
95 });
96
97 // when "dojo/ready" is ready call parser.parse (if not doing parseOnLoad)
98 ready(function(){
99 parser.parse();
100 });
101
102
103 // called to reset the model for each of the repeats
104 swapToModel1 = function() {
105 registry.byId('repeatId1').set('children',model1.Results);
106 registry.byId('repeatId2').set('children',model1.Results);
107 };
108
109 swapToModel2 = function() {
110 registry.byId('repeatId1').set('children',model2.Results);
111 registry.byId('repeatId2').set('children',model2.Results);
112 };
113
114 resetAll = function() {
115 model1 = lang.clone(model1Orig);
116 model2 = lang.clone(model2Orig);
117 registry.byId('repeatId1').set('children',model1.Results);
118 registry.byId('repeatId2').set('children',model1.Results);
119 };
120
121
122 });
123
124 </script>
125 </head>
126 <body style="visibility:hidden;">
127 <script type="dojo/require">at: "dojox/mvc/at"</script>
128 <div id="wrapper">
129 <div id="header">
130 <div id="navigation"></div>
131 <div id="headerInsert">
132 <h2>MVC Repeat with Selectable RoundRectDataList - Single Select</h2>
133 </div>
134 </div>
135 <div id="main">
136 <div id="leftNav"></div>
137 <div id="mainContent">
138 <h4>Here is one using dojox.mvc.Repeat as a mixin with no Group and dojo.parser instead of dojox.mobile.parser it is all good using mixin.</h4>
139 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatId1" select="single"
140 data-dojo-mixins="dojox/mvc/WidgetList"
141 data-mvc-child-type="dojox/mobile/ListItem"
142 data-mvc-child-props="label: at(this.target, 'First'), checked: at(this.target, 'Checked'), variableHeight: true"
143 data-dojo-props="children: model1.Results">
144 </ul>
145 <h4>You can update the label or checked from here to update the model.</h4>
146 <div id="repeatId2" data-dojo-type="dojox/mvc/WidgetList"
147 data-dojo-mixins="dojox/mvc/_InlineTemplateMixin"
148 data-dojo-props="children: model1.Results">
149 <script type="dojox/mvc/InlineTemplate">
150 <div>
151 <input class="cell"
152 data-dojo-type="dojox/mobile/TextBox"
153 data-dojo-props="value: at('rel:', 'First')">
154 <label for="CBInput${indexAtStartup}"
155 data-dojo-type="dijit/_WidgetBase"
156 data-dojo-props="_setValueAttr: {node: 'domNode', type: 'innerText'}, value: at('rel:', 'First')"></label>
157 <input class="cell" type="checkbox" id="CBInput${indexAtStartup}"
158 data-dojo-type="dojox/mobile/CheckBox"
159 data-dojo-props="checked: at('rel:', 'Checked')">
160 </div>
161 </script>
162 </div>
163 <br/>Model:
164 <button type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){swapToModel2();}">Swap Model2</button>
165 <button type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){swapToModel1();}">Swap Model1</button>
166 <button id="reset" type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){resetAll();}">Reset all</button>
167 </div>
168 </div>
169 </div>
170 </body>
171 </html>