| 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 | <style type="text/css"> |
| 7 | @import "../css/app-format.css"; |
| 8 | </style> |
| 9 | <script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1,mvc:{debugBindings:1}" src="../../../../dojo/dojo.js"></script> |
| 10 | <script type="text/javascript"> |
| 11 | var ctrl, ctrlDetail, model, data; |
| 12 | |
| 13 | require([ |
| 14 | "doh/runner", |
| 15 | "dojo/parser", |
| 16 | "dojo/Stateful", |
| 17 | "dojo/dom", |
| 18 | "dojo/when", |
| 19 | "dojox/mvc/getStateful", |
| 20 | "dojox/mvc/ModelRefController", |
| 21 | "dojox/mvc/Group", |
| 22 | "dojox/mvc/parserExtension", |
| 23 | "dojo/domReady!" |
| 24 | ], function(doh, parser, Stateful, dom, when, getStateful, ModelRefController){ |
| 25 | |
| 26 | ctrl = new ModelRefController(); |
| 27 | ctrlDetail = new ModelRefController(); |
| 28 | |
| 29 | when(parser.parse(), function(){ |
| 30 | data = { |
| 31 | "Serial": "360324", |
| 32 | "First": "John", |
| 33 | "Last": "Doe", |
| 34 | "Email": "[email protected]", |
| 35 | "ShipTo": { |
| 36 | "Street": "123 Valley Rd-ShipTo", |
| 37 | "City": "Katonah", |
| 38 | "State": "NY", |
| 39 | "Zip": "10536" |
| 40 | }, |
| 41 | "BillTo": { |
| 42 | "Street": "17 Skyline Dr-BillTo", |
| 43 | "City": "Hawthorne", |
| 44 | "State": "NY", |
| 45 | "Zip": "10532" |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | ctrl.set("model", getStateful(data)); |
| 50 | ctrlDetail.set("model", ctrl.model.get("ShipTo")); |
| 51 | |
| 52 | doh.register("Switch between ShipTo and BillTo", [{ |
| 53 | name: "Switch-to-BillTo", |
| 54 | runTest: function(){ |
| 55 | ctrlDetail.set("model", ctrl.model.get("BillTo")); |
| 56 | doh.is("17 Skyline Dr-BillTo", dom.byId("streetInput").value, "Street should be of BillTo"); |
| 57 | doh.is("Hawthorne", dom.byId("cityInput").value, "City should be of BillTo"); |
| 58 | } |
| 59 | }, { |
| 60 | name: "Switch-to-ShipTo", |
| 61 | runTest: function(){ |
| 62 | ctrlDetail.set("model", ctrl.model.get("ShipTo")); |
| 63 | doh.is("123 Valley Rd-ShipTo", dom.byId("streetInput").value, "Street should be of ShipTo"); |
| 64 | doh.is("Katonah", dom.byId("cityInput").value, "City should be of ShipTo"); |
| 65 | } |
| 66 | }]); |
| 67 | |
| 68 | doh.run(); |
| 69 | }); |
| 70 | }); |
| 71 | </script> |
| 72 | </head> |
| 73 | <body class="claro"> |
| 74 | <script type="dojo/require">at: "dojox/mvc/at"</script> |
| 75 | <div id="wrapper"> |
| 76 | <div id="header"> |
| 77 | <div id="navigation"> |
| 78 | </div> |
| 79 | <div id="headerInsert"> |
| 80 | <h1>Order Shipping Details</h1> |
| 81 | <h2>Data Binding Example - Group Container.</h2> |
| 82 | </div> |
| 83 | </div> |
| 84 | <div id="main"> |
| 85 | <div id="leftNav"></div> |
| 86 | <div id="mainContent"> |
| 87 | <div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrl, 'model')"> |
| 88 | <div class="row"> |
| 89 | <label class="cell" for="serialInput">Order #:</label> |
| 90 | <input class="cell" id="serialInput" |
| 91 | data-mvc-bindings="value: at('rel:', 'Serial')"> |
| 92 | </div> |
| 93 | <div class="row"> |
| 94 | <label class="cell" for="lastnameInput">Last:</label> |
| 95 | <input class="cell" id="lastnameInput" |
| 96 | data-mvc-bindings="value: at('rel:', 'Last')"> |
| 97 | </div> |
| 98 | <div class="row"> |
| 99 | <label class="cell" for="emailInput">Email:</label> |
| 100 | <input class="cell" id="emailInput" |
| 101 | data-mvc-bindings="value: at('rel:', 'Email')"> |
| 102 | </div> |
| 103 | </div> |
| 104 | <br/> |
| 105 | <div class="row" id="addrGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(ctrlDetail, 'model')"> |
| 106 | <div class="row"> |
| 107 | <label class="cell" for="streetInput">Street:</label> |
| 108 | <input class="cell" id="streetInput" |
| 109 | data-mvc-bindings="value: at('rel:', 'Street')"> |
| 110 | </div> |
| 111 | <div class="row"> |
| 112 | <label class="cell" for="cityInput">City:</label> |
| 113 | <input class="cell" id="cityInput" |
| 114 | data-mvc-bindings="value: at('rel:', 'City')"> |
| 115 | </div> |
| 116 | <div class="row"> |
| 117 | <label class="cell" for="stateInput">State:</label> |
| 118 | <input class="cell" id="stateInput" |
| 119 | data-mvc-bindings="value: at('rel:', 'State')"> |
| 120 | </div> |
| 121 | <div class="row"> |
| 122 | <label class="cell" for="zipInput">Zipcode:</label> |
| 123 | <input class="cell" id="zipInput" |
| 124 | data-mvc-bindings="value: at('rel:', 'Zip')"> |
| 125 | </div> |
| 126 | </div> |
| 127 | </div></div></div> |
| 128 | </body> |
| 129 | </html> |