| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 | <title>Static Master/Detail Pattern -- Multiple Address Detail example</title> |
| 6 | |
| 7 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="parseOnLoad: 0, isDebug: true, mvc: {debugBindings: true}"> |
| 8 | </script> |
| 9 | <style type="text/css"> |
| 10 | @import "css/app-format.css"; |
| 11 | @import "../../../dijit/themes/claro/claro.css"; |
| 12 | </style> |
| 13 | <script type="text/javascript" > |
| 14 | var model1 = [ |
| 15 | { |
| 16 | First: "Anne1", |
| 17 | Last: "Ackerman1" |
| 18 | }, |
| 19 | { |
| 20 | First: "Ben1", |
| 21 | Last: "Beckham1" |
| 22 | }, |
| 23 | { |
| 24 | First: "Chad1", |
| 25 | Last: "Chapman1" |
| 26 | } |
| 27 | ], model2 = [ |
| 28 | { |
| 29 | First: "Anne2", |
| 30 | Last: "Ackerman2" |
| 31 | }, |
| 32 | { |
| 33 | First: "Ben2", |
| 34 | Last: "Beckham2" |
| 35 | } |
| 36 | ], model3 = [ |
| 37 | { |
| 38 | First: "", |
| 39 | Last: "" |
| 40 | } |
| 41 | ], showOutput; |
| 42 | |
| 43 | require([ |
| 44 | "dojo/parser", |
| 45 | "dijit/registry", |
| 46 | "dijit/_Container", |
| 47 | "dijit/form/TextBox", |
| 48 | "dijit/form/Button", |
| 49 | "dojox/mvc/Group", |
| 50 | "dojox/mvc/Output", |
| 51 | "dojox/mvc/Repeat", |
| 52 | "dojo/domReady!" |
| 53 | ], function(parser, registry){ |
| 54 | |
| 55 | refreshOutput = function(){ |
| 56 | registry.byId("out1").set("target", model1.slice()); |
| 57 | registry.byId("out2").set("target", model2.slice()); |
| 58 | registry.byId("out3").set("target", model3.slice()); |
| 59 | } |
| 60 | |
| 61 | parser.parse(); |
| 62 | }); |
| 63 | </script> |
| 64 | </head> |
| 65 | <body class="claro"> |
| 66 | <script type="dojo/require">at: "dojox/mvc/at"</script> |
| 67 | <div id="wrapper"> |
| 68 | <div id="header"> |
| 69 | <div id="navigation"></div> |
| 70 | <div id="headerInsert"> |
| 71 | <h1>Input Output Sync</h1> |
| 72 | <h2>Data Binding Example</h2> |
| 73 | </div> |
| 74 | </div> |
| 75 | <div id="main"> |
| 76 | <div id="leftNav"></div> |
| 77 | <div id="mainContent"> |
| 78 | <div class="row"> |
| 79 | <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ dijit.byId('repeatId').set('children', model1); }">Swap Model1</button> |
| 80 | <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ dijit.byId('repeatId').set('children', model2); }">Swap Model2</button> |
| 81 | <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){ dijit.byId('repeatId').set('children', model3); }">Swap Model3</button> |
| 82 | </div> |
| 83 | <div id="repeatId" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="children: model1"> |
| 84 | <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at('rel:${this.index}')"> |
| 85 | <label class="cell" for="nameInput${this.index}">Name:</label> |
| 86 | <input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" |
| 87 | data-dojo-props="value: at('rel:', 'First')"> |
| 88 | </div> |
| 89 | </div> |
| 90 | <div class="row"> |
| 91 | <div>Given the data models are not stateful objects, the change in models is not automatically notified to widgets.</div> |
| 92 | <button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: refreshOutput">Refresh model outputs</button> |
| 93 | </div> |
| 94 | <div id="out1" class="row" data-dojo-type="dijit._WidgetBase" data-dojo-props="target: model1"> |
| 95 | <span> |
| 96 | Model1 Output is ==> |
| 97 | </span> |
| 98 | Name1 is "<span id="firstnameOutput10" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at('rel:0', 'First')"></span>" : |
| 99 | Name2 is "<span id="firstnameOutput11" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at('rel:1', 'First')"></span>" : |
| 100 | Name3 is "<span id="firstnameOutput12" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at('rel:2', 'First')"></span>" |
| 101 | </div> |
| 102 | <div id="out2" class="row" data-dojo-type="dijit._WidgetBase" data-dojo-props="target: model2"> |
| 103 | <span> |
| 104 | Model2 Output is ==> |
| 105 | </span> |
| 106 | Name1 is "<span id="firstnameOutput20" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at('rel:0', 'First')"></span>" : |
| 107 | Name2 is "<span id="firstnameOutput21" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at('rel:1', 'First')"></span>" |
| 108 | </div> |
| 109 | <div id="out3" class="row" data-dojo-type="dijit._WidgetBase" data-dojo-props="target: model3"> |
| 110 | <span> |
| 111 | Model3 Output is ==> |
| 112 | </span> |
| 113 | Name1 is "<span id="firstnameOutput30" data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at('rel:0', 'First')"></span>" |
| 114 | </div> |
| 115 | </div> |
| 116 | </div> |
| 117 | </div> |
| 118 | </body> |
| 119 | </html> |