| 1 |
<!DOCTYPE html> |
| 2 |
<html > |
| 3 |
<head> |
| 4 |
|
| 5 |
<style type="text/css"> |
| 6 |
@import "../../../../dijit/themes/claro/claro.css"; |
| 7 |
</style> |
| 8 |
<style type="text/css"> |
| 9 |
/* BEGIN .. css :: Things in this section have to be two tabs in */ |
| 10 |
|
| 11 |
.row { width: 500px; display: inline-block; margin: 5px; } |
| 12 |
.cell { width: 20%; display:inline-block; } |
| 13 |
|
| 14 |
/* END .. css :: Things in this section have to be two tabs in */ |
| 15 |
</style> |
| 16 |
<script src="../../../../dojo/dojo.js" data-dojo-config='parseOnLoad: false, mvc: {debugBindings: true}'></script><script>var searchRecords; |
| 17 |
|
| 18 |
/* BEGIN .. js :: Things in this section have to be two tabs in */ |
| 19 |
|
| 20 |
var templateString2 = '<div class="row">' |
| 21 |
+ '<script type="dojo/require">at: "dojox/mvc/at"<\/script>' |
| 22 |
+ '<label class="cell">Name:</label>' |
| 23 |
+ '<input id="${parent.id}_textbox${indexAtStartup}" class="cell" data-dojo-type="dijit/form/TextBox" data-dojo-attach-point="firstNode"></input>' |
| 24 |
+ '<input class="cell" data-dojo-type="dijit/form/TextBox" data-dojo-attach-point="lastNode"></input>' |
| 25 |
+ '</div>'; |
| 26 |
|
| 27 |
|
| 28 |
require([ |
| 29 |
"dojo/_base/declare", |
| 30 |
"dojo/when", |
| 31 |
"dojo/dom", |
| 32 |
"dojo/parser", |
| 33 |
"dojo/promise/all", |
| 34 |
"dojo/store/Memory", |
| 35 |
"dojox/mvc/at", |
| 36 |
"dijit/registry", |
| 37 |
"dijit/_WidgetBase", |
| 38 |
"dojox/mvc/EditStoreRefListController", |
| 39 |
"dojox/mvc/WidgetList", |
| 40 |
"dijit/form/TextBox", |
| 41 |
"dojox/mvc/Group", |
| 42 |
"dojo/domReady!" |
| 43 |
], function(declare, when, ddom, parser, all, Memory, at, registry, _WidgetBase, EditStoreRefListController, WidgetList){ |
| 44 |
|
| 45 |
// Initial data |
| 46 |
var data = { |
| 47 |
"identifier": "Serial", |
| 48 |
"items": [ |
| 49 |
{ |
| 50 |
"Serial" : "A111", |
| 51 |
"First" : "Anne", |
| 52 |
"Last" : "Ackerman", |
| 53 |
"Email" : "[email protected]" |
| 54 |
}, |
| 55 |
{ |
| 56 |
"Serial" : "B111", |
| 57 |
"First" : "Ben", |
| 58 |
"Last" : "Beckham", |
| 59 |
"Email" : "[email protected]" |
| 60 |
}, |
| 61 |
{ |
| 62 |
"Serial" : "I111", |
| 63 |
"First" : "Irene", |
| 64 |
"Last" : "Ira", |
| 65 |
"Email" : "[email protected]" |
| 66 |
}, |
| 67 |
{ |
| 68 |
"Serial" : "J111", |
| 69 |
"First" : "John", |
| 70 |
"Last" : "Jacklin", |
| 71 |
"Email" : "[email protected]" |
| 72 |
} |
| 73 |
] |
| 74 |
}; |
| 75 |
|
| 76 |
ctrl = new EditStoreRefListController({store: new Memory({data: data})}); |
| 77 |
|
| 78 |
// Programmatic WidgetList using childBindings and a templateString using attach-points |
| 79 |
(new WidgetList({templateString: templateString2, |
| 80 |
children: at(ctrl, "model"), |
| 81 |
childBindings: { |
| 82 |
firstNode: {value: at("rel:", "First")}, |
| 83 |
lastNode: {value: at("rel:", "Last")} |
| 84 |
}}, |
| 85 |
ddom.byId("programmaticRepeat1"))).startup(); |
| 86 |
|
| 87 |
// Programatic WidgetList using childParams and startup function to setup bindings with templateString using attach-points |
| 88 |
(new WidgetList({templateString: templateString2, |
| 89 |
children: at(ctrl, "model"), |
| 90 |
childParams: { |
| 91 |
startup: function(){ |
| 92 |
this.firstNode.set("value", at("rel:", "First")); |
| 93 |
this.lastNode.set("value", at("rel:", "Last")); |
| 94 |
this.inherited("startup", arguments); |
| 95 |
}}}, |
| 96 |
ddom.byId("programmaticRepeat2"))).startup(); |
| 97 |
|
| 98 |
when(all([parser.parse(), ctrl.queryStore()]), function(a){ |
| 99 |
console.log("parser.parse and queryStore are complete ctrl.model is set to from the query",a[1]); |
| 100 |
}); |
| 101 |
|
| 102 |
}); |
| 103 |
|
| 104 |
/* END .. js :: */ |
| 105 |
|
| 106 |
</script> |
| 107 |
</head> |
| 108 |
<body class="claro"> |
| 109 |
|
| 110 |
|
| 111 |
<div id="main"> |
| 112 |
<h4>Programatic WidgetList using childBindings to setup the bindings with a templateString using attach-points: </h4> |
| 113 |
<div id="programmaticRepeat1"></div> |
| 114 |
<h4>Programatic WidgetList using childParams and startup function to setup bindings with templateString using attach-points: </h4> |
| 115 |
<div id="programmaticRepeat2"></div> |
| 116 |
<p>In the above example, the TextBoxes inside the WidgetList are bound to the same model, so updates in one list will be reflected in the other. |
| 117 |
</div> |
| 118 |
|
| 119 |
|
| 120 |
</body> |
| 121 |
</html> |