| 1 |
<!DOCTYPE html> |
| 2 |
<html style="width:100%;height:100%;overflow:hidden;"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>MVC repeated widget test</title> |
| 6 |
|
| 7 |
<style type="text/css"> |
| 8 |
@import "../../../dijit/themes/dijit.css"; |
| 9 |
@import "../../../dijit/themes/claro/document.css"; |
| 10 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 11 |
</style> |
| 12 |
|
| 13 |
|
| 14 |
<link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/> |
| 15 |
|
| 16 |
|
| 17 |
<script type="text/javascript"> |
| 18 |
dojoConfig = { |
| 19 |
isDebug: 1, |
| 20 |
parseOnLoad: 0, |
| 21 |
async: 1, |
| 22 |
mvc: {debugBindings: 1} |
| 23 |
}; |
| 24 |
</script> |
| 25 |
<script type="text/javascript" src="../../../dojo/dojo.js"></script> |
| 26 |
|
| 27 |
<script type="text/javascript"> |
| 28 |
require([ |
| 29 |
"dojo/dom", |
| 30 |
"dojo/dom-class", |
| 31 |
"dojo/parser", |
| 32 |
"dijit/_WidgetBase", |
| 33 |
"dojox/mvc/at", |
| 34 |
"dojox/mvc/getStateful", |
| 35 |
"dojox/mvc/Templated", |
| 36 |
"dojox/mvc/WidgetList", |
| 37 |
"dojo/text!dojox/mvc/tests/test_WidgetList_childTemplate.html", |
| 38 |
"dojo/text!dojox/mvc/tests/test_WidgetList_childBindings.json", |
| 39 |
"dijit/form/TextBox" // dijit._WidgetsInTemplateMixin does not support auto-loading modules by parser |
| 40 |
], function(dom, domClass, parser, _WidgetBase, at, getStateful, Templated, WidgetList, childTemplate, childBindings){ |
| 41 |
array = getStateful([ |
| 42 |
{ |
| 43 |
Serial: "A111", |
| 44 |
First: "Anne", |
| 45 |
Last: "Ackerman", |
| 46 |
Location: "NY", |
| 47 |
Office: "1S76", |
| 48 |
Email: "[email protected]", |
| 49 |
Tel: "123-764-8237", |
| 50 |
Fax: "123-764-8228" |
| 51 |
}, |
| 52 |
{ |
| 53 |
Serial: "B111", |
| 54 |
First: "Ben", |
| 55 |
Last: "Beckham", |
| 56 |
Location: "NY", |
| 57 |
Office: "5N47", |
| 58 |
Email: "[email protected]", |
| 59 |
Tel: "123-764-8599", |
| 60 |
Fax: "123-764-8600" |
| 61 |
}, |
| 62 |
{ |
| 63 |
Serial: "C111", |
| 64 |
First: "Chad", |
| 65 |
Last: "Chapman", |
| 66 |
Location: "CA", |
| 67 |
Office: "1278", |
| 68 |
Email: "[email protected]", |
| 69 |
Tel: "408-764-8237", |
| 70 |
Fax: "408-764-8228" |
| 71 |
} |
| 72 |
]); |
| 73 |
|
| 74 |
arrayAlt = getStateful([ |
| 75 |
{ |
| 76 |
Serial: "D111", |
| 77 |
First: "David", |
| 78 |
Last: "Durham", |
| 79 |
Location: "NJ", |
| 80 |
Office: "C12", |
| 81 |
Email: "[email protected]", |
| 82 |
Tel: "514-764-8237", |
| 83 |
Fax: "514-764-8228" |
| 84 |
}, |
| 85 |
{ |
| 86 |
Serial: "E111", |
| 87 |
First: "Emma", |
| 88 |
Last: "Eklof", |
| 89 |
Location: "NY", |
| 90 |
Office: "4N76", |
| 91 |
Email: "[email protected]", |
| 92 |
Tel: "123-764-1234", |
| 93 |
Fax: "123-764-4321" |
| 94 |
} |
| 95 |
]); |
| 96 |
|
| 97 |
domClass.add(dom.byId("loading"), "dijitDisplayNone"); |
| 98 |
domClass.remove(dom.byId("main"), "dijitDisplayNone"); |
| 99 |
parser.parse(); |
| 100 |
|
| 101 |
(new WidgetList({ |
| 102 |
children: array, |
| 103 |
childParams: { |
| 104 |
startup: function(){ |
| 105 |
this.labelNode.set("value", at("rel:", "Serial")); |
| 106 |
this.inputNode.set("value", at("rel:", "First")); |
| 107 |
this.inherited("startup", arguments); |
| 108 |
} |
| 109 |
}, |
| 110 |
templateString: childTemplate |
| 111 |
}, dom.byId("programmaticRepeat"))).startup(); |
| 112 |
|
| 113 |
(new WidgetList({ |
| 114 |
children: array, |
| 115 |
templateString: childTemplate, |
| 116 |
childBindings: eval("(" + childBindings + ")") |
| 117 |
}, dom.byId("programmaticRepeatWithSeparateBindingDeclaration"))).startup(); |
| 118 |
}); |
| 119 |
</script> |
| 120 |
</head> |
| 121 |
<body class="claro" style="width:100%;height:100%;margin:0;padding:8px;overflow:hidden;"> |
| 122 |
<script type="dojo/require">at: "dojox/mvc/at", Stateful: "dojo/Stateful"</script> |
| 123 |
<table id="loading" style="width:100%;height:100%;" border="0" cellpadding="0" cellspacing="0"> |
| 124 |
<tbody> |
| 125 |
<tr> |
| 126 |
<td align="center">Loading...</td> |
| 127 |
</tr> |
| 128 |
</tbody> |
| 129 |
</table> |
| 130 |
<div id="main" class="dijitDisplayNone" style="width:100%;height:100%;"> |
| 131 |
<div> |
| 132 |
<h1>Repeating simple text box and label</h1> |
| 133 |
<div data-dojo-type="dojox/mvc/WidgetList" |
| 134 |
data-dojo-props="children: array" |
| 135 |
data-mvc-child-type="dijit/form/TextBox" |
| 136 |
data-mvc-child-props="value: at(this.target, 'First')"></div> |
| 137 |
<span data-dojo-type="dojox/mvc/WidgetList" |
| 138 |
data-dojo-props="children: array" |
| 139 |
data-mvc-child-type="dijit/_WidgetBase" |
| 140 |
data-mvc-child-props="_setValueAttr: {node: 'domNode', type: 'innerText'}, value: at(this.target, 'First')"></span> |
| 141 |
</div> |
| 142 |
<div> |
| 143 |
<h1>Repeating in-line template</h1> |
| 144 |
<div data-dojo-type="dojox/mvc/WidgetList" |
| 145 |
data-dojo-mixins="dojox/mvc/_InlineTemplateMixin" |
| 146 |
data-dojo-props="children: array, partialRebuild: true"> |
| 147 |
<script type="dojox/mvc/InlineTemplate"> |
| 148 |
<div> |
| 149 |
<span data-dojo-type="dijit/_WidgetBase" |
| 150 |
data-dojo-props="_setValueAttr: {node: 'domNode', type: 'innerText'}, value: at('rel:', 'Serial')"></span>: |
| 151 |
<span data-dojo-type="dijit/form/TextBox" |
| 152 |
data-dojo-props="value: at('rel:', 'First')"></span> |
| 153 |
</div> |
| 154 |
</script> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
<div> |
| 158 |
<h1>Repeating programmatically created template widget</h1> |
| 159 |
<div id="programmaticRepeat"></div> |
| 160 |
</div> |
| 161 |
<div> |
| 162 |
<h1>Repeating programmatically created template widget, with separate data binding declaration from template</h1> |
| 163 |
<div id="programmaticRepeatWithSeparateBindingDeclaration"></div> |
| 164 |
</div> |
| 165 |
<div> |
| 166 |
<h1>Modifying array elements</h1> |
| 167 |
<input type="button" value="Replace" onclick="array.splice.apply(array, [1, 1].concat(arrayAlt)); this.disabled = true;"> |
| 168 |
</div> |
| 169 |
</div> |
| 170 |
</body> |
| 171 |
</html> |