Debian Codegraph @

dojox/mvc/tests/mobile/test_mobile-list-multiple-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 - Multiple 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/store/Memory",
21 "dojo/ready",
22 "dojo/when",
23 "dojox/mvc/getStateful",
24 "dojox/mvc/at",
25 "dojox/mvc/Group",
26 "dojox/mvc/Repeat",
27 "dojox/mvc/Output",
28 "dojox/mobile",
29 "dojox/mobile/Button",
30 "dojox/mobile/TextBox",
31 "dojox/mobile/CheckBox",
32 "dojox/mobile/deviceTheme"
33 ], function(lang, registry, parser, MemoryStore, ready, when, getStateful, at){
34 window.at = at;
35
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 registry.byId('repeatid2arem').set('children',model1.Results);
108 };
109
110 swapToModel2 = function() {
111 registry.byId('repeatId1').set('children',model2.Results);
112 registry.byId('repeatId2').set('children',model2.Results);
113 registry.byId('repeatid2arem').set('children',model2.Results);
114 };
115
116 resetAll = function() {
117 model1 = lang.clone(model1Orig);
118 model2 = lang.clone(model2Orig);
119 registry.byId('repeatId1').set('children',model1.Results);
120 registry.byId('repeatId2').set('children',model1.Results);
121 registry.byId('repeatid2arem').set('children',model1.Results);
122 };
123
124
125 });
126
127 </script>
128 </head>
129 <body style="visibility:hidden;">
130 <script type="dojo/require">at: "dojox/mvc/at"</script>
131 <div id="wrapper">
132 <div id="header">
133 <div id="navigation"></div>
134 <div id="headerInsert">
135 <h2>MVC Repeat with Selectable RoundRectList - Multiple Select</h2>
136 </div>
137 </div>
138 <div id="main">
139 <div id="leftNav"></div>
140 <div id="mainContent">
141 <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>
142 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatId1" select="multiple"
143 data-dojo-mixins="dojox.mvc.Repeat" data-dojo-props="exprchar:'#', children: model1.Results">
144 <li id="configure_itemmix1#{this.index}" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
145 data-dojo-props="label: at('rel:#{this.index}', 'First'),
146 checked: at('rel:#{this.index}', 'Checked')">
147 </li>
148 </ul>
149
150 <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>
151 <ul data-dojo-type="dojox.mobile.RoundRectList" id="repeatparentidrem" select="multiple">
152 <div data-dojo-type="dojox.mvc.Repeat" id="repeatid2arem"
153 data-dojo-props="exprchar:'#', children:model1.Results, removeRepeatNode:true">
154 <li id="configure_itemrem#{this.index}" class="mblVariableHeight" data-dojo-type="dojox.mobile.ListItem"
155 data-dojo-props="label: at('rel:#{this.index}','First'),
156 checked: at('rel:#{this.index}','Checked')">
157 </li>
158 </div>
159 </ul>
160 <h4>You can update the label or checked from here to update the model.</h4>
161 <div id="repeatparentid2">
162 <div id="repeatId2" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="children:model1.Results">
163 <input class="cell" data-dojo-type="dojox.mobile.TextBox" id="nameInput2${this.index}"
164 data-dojo-props="value: at('rel:${this.index}', 'First')"/>
165 <label data-dojo-type="dojox.mvc.Output" for="CBInput${this.index}"
166 data-dojo-props="value: at('rel:${this.index}','First')"/></label>
167 <input class="cell" type="checkbox" data-dojo-type="dojox.mobile.CheckBox" id="CBInput${this.index}"
168 data-dojo-props="checked: at('rel:${this.index}','Checked')"/>
169 </div>
170 </div>
171
172 <br/>Model:
173 <button type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){swapToModel2();}">Swap Model2</button>
174 <button type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){swapToModel1();}">Swap Model1</button>
175 <button id="reset" type="button" data-dojo-type="dojox.mobile.Button" data-dojo-props="onClick: function(){resetAll();}">Reset all</button>
176 </div>
177 </div>
178 </div>
179 </body>
180 </html>