Debian Codegraph @

dojox/mvc/tests/1.7/mobile/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"></script>
14
15 <script type="text/javascript">
16 require([
17 "dojox",
18 "dojox/mvc",
19 //"dojox/mobile/parser",
20 "dojo/parser",
21 "dojo/store/Memory",
22 "dojo/ready",
23 "dojox/mvc/_patches",
24 "dojox/mvc/at",
25 "dojox/mvc/Group",
26 "dojox/mvc/Repeat",
27 "dojox/mvc/Output",
28 "dojox/mobile",
29 "dojox/mobile/ScrollableView",
30 "dojox/mobile/Button",
31 "dojox/mobile/TextArea",
32 "dojox/mobile/TextBox",
33 "dojox/mobile/CheckBox",
34 "dojox/mobile/ViewController",
35 "dojox/mobile/FixedSplitter",
36 "dojox/mobile/EdgeToEdgeList",
37 "dojox/mobile/EdgeToEdgeCategory",
38 "dojox/mobile/deviceTheme",
39 "dojox/mobile/RoundRectCategory",
40 "dojox/mobile/Heading"
41 ], function(dojox, mvc, parser, MemoryStore, ready){
42
43
44 var search_results_init1 =
45 [{
46 "Query" : "Engineers1",
47 "Results" : [
48 {
49 "First" : "Anne1",
50 "Last" : "Ackerman1",
51 "Checked" : true
52 },
53 {
54 "First" : "Ben1",
55 "Last" : "Beckham1",
56 "Checked" : false
57 },
58 {
59 "First" : "Chad1",
60 "Last" : "Chapman1",
61 "Checked" : false
62 }
63 ]
64 }];
65
66 var search_results_init2 =
67 [{
68 "Query" : "Engineers1",
69 "Results" : [
70 {
71 "First" : "Anne2",
72 "Last" : "Ackerman2",
73 "Checked" : false
74 },
75 {
76 "First" : "Ben2",
77 "Last" : "Beckham2",
78 "Checked" : true
79 },
80 {
81 "First" : "Chad2",
82 "Last" : "Chapman2",
83 "Checked" : false
84 }
85 ]
86 }];
87 var memStore1 = new MemoryStore({data : search_results_init1});
88 model1 = mvc.newStatefulModel({ store : memStore1 })[0];
89
90 var memStore2 = new MemoryStore({data : search_results_init2});
91 model2 = mvc.newStatefulModel({ store : memStore2 })[0];
92
93 // when "dojo/ready" is ready call parser.parse (if not doing parseOnLoad)
94 ready(function(){
95 parser.parse();
96 });
97
98
99
100 });
101
102 // called to reset the model for each of the repeats
103 function swapToModel1() {
104 dijit.byId('repeatId1').set('ref',model1.Results);
105 dijit.byId('repeatId2').set('ref',model1.Results);
106 dijit.byId('repeatid2arem').set('ref',model1.Results);
107 dijit.byId('repeatid2aremg').set('ref',model1.Results);
108 dijit.byId('repeatid2a').set('ref',model1.Results);
109 };
110
111 function swapToModel2() {
112 dijit.byId('repeatId1').set('ref',model2.Results);
113 dijit.byId('repeatId2').set('ref',model2.Results);
114 dijit.byId('repeatid2arem').set('ref',model2.Results);
115 dijit.byId('repeatid2aremg').set('ref',model2.Results);
116 dijit.byId('repeatid2a').set('ref',model2.Results);
117 };
118
119
120 </script>
121 </head>
122 <body style="visibility:hidden;">
123 <div id="wrapper">
124 <div id="header">
125 <div id="navigation"></div>
126 <div id="headerInsert">
127 <h2>MVC Repeat with Selectable RoundRectDataList - Single Select</h2>
128 </div>
129 </div>
130 <div id="main">
131 <div id="leftNav"></div>
132 <div id="mainContent">
133 <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>
134 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatId1" select="single"
135 data-dojo-mixins="dojox.mvc.Repeat" data-dojo-props="exprchar:'#', ref:'model1.Results'">
136 <li id="configure_itemmix1#{this.index}" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
137 data-dojo-props="label: dojox.mvc.at('rel:#{this.index}.First', 'value'),
138 checked: dojox.mvc.at('rel:#{this.index}.Checked', 'value')">
139 </li>
140 </ul>
141
142 <h4>Here is one using MVC using Repeat no Group, with removeRepeatNode set true it is all good if Repeat sets select and onCheckStateChanged.</h4>
143 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatparentidrem" select="single">
144 <div data-dojo-type="dojox.mvc.Repeat" id="repeatid2arem" data-dojo-props="exprchar:'#', ref:'model1.Results', removeRepeatNode:true">
145 <li id="configure_itemrem#{this.index}" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
146 data-dojo-props="label: dojox.mvc.at('rel:#{this.index}.First', 'value'),
147 checked: dojox.mvc.at('rel:#{this.index}.Checked', 'value')">
148 </li>
149 </div>
150 </ul>
151
152 <h4>Here is one using MVC using Repeat with a Group, with removeRepeatNode set true it is all good if Repeat sets select and onCheckStateChanged.</h4>
153 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatparentidremg" select="single">
154 <div data-dojo-type="dojox.mvc.Repeat" id="repeatid2aremg" data-dojo-props="exprchar:'#', ref:'model1.Results', removeRepeatNode:true">
155 <div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '#{this.index}'">
156 <li id="configure_itemremg#{this.index}" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
157 data-dojo-props="label: dojox.mvc.at('rel:First', 'value'),
158 checked: dojox.mvc.at('rel:Checked', 'value')">
159 </li>
160 </div>
161 </div>
162 </ul>
163
164 <h4>You can update the label or checked from here to update the model.</h4>
165 <div id="repeatparentid2">
166 <div id="repeatId2" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref:'model1.Results'">
167 <input class="cell" data-dojo-type="dojox.mobile.TextBox" id="nameInput2${this.index}"
168 data-dojo-props="value: dojox.mvc.at('rel:${this.index}.First', 'value')"/>
169 <label data-dojo-type="dojox.mvc.Output" for="CBInput${this.index}"
170 data-dojo-props="value: dojox.mvc.at('rel:${this.index}.First', 'value')"/></label>
171 <input class="cell" type="checkbox" data-dojo-type="dojox.mobile.CheckBox" id="CBInput${this.index}"
172 data-dojo-props="checked: dojox.mvc.at('rel:${this.index}.Checked', 'value')"/>
173 </div>
174 </div>
175
176 <br/>Model:
177 <button type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){swapToModel2();}">Swap Model2</button>
178 <button type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){swapToModel1();}">Swap Model1</button>
179 <button id="reset" type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){model1.reset();model2.reset();}">Reset all</button>
180
181 <h4>Here is one using MVC using Repeat no Group, using useParent it has style and
182 selection problems because of the Group nodes, updates to the model are reflected here, looks good, but has selection problems...
183 Also the Swap model buttons do not work with this one.
184 </h4>
185 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatparentid" select="single">
186 <div data-dojo-type="dojox.mvc.Repeat" id="repeatid2a" data-dojo-props="exprchar:'#', ref:'model1.Results', useParent:'repeatparentid'">
187 <li id="configure_item#{this.index}" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
188 data-dojo-props="label: dojox.mvc.at('model1.Results.#{this.index}.First', 'value'),
189 checked: dojox.mvc.at('model1.Results.#{this.index}.Checked', 'value')">
190 </li>
191 </div>
192 </ul>
193
194
195 <!--
196 <h4>Here is a normal RoundRectList for comparison Item one should be selected</h4>
197 <ul id="list1a" data-dojo-type="dojox.mobile.RoundRectList" select="single" >
198 <li id="configure_itemXX0" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
199 data-dojo-props="label: dojox.mvc.at(model1.Results[0].First, 'value'),
200 checked: dojox.mvc.at(model1.Results[0].Checked, 'value')">
201 </li>
202 <li id="configure_itemXX1" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
203 data-dojo-props="label: dojox.mvc.at(model1.Results[1].First, 'value'),
204 checked: dojox.mvc.at(model1.Results[1].Checked, 'value')">
205 </li>
206 </ul>
207 -->
208 </div>
209 </div>
210 </div>
211 </body>
212 </html>