| 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 |
@import "../../../../dijit/themes/claro/claro.css"; |
| 9 |
</style> |
| 10 |
<script type="text/javascript" djConfig="parseOnLoad:1,isDebug:1,async:1" src="../../../../dojo/dojo.js"></script> |
| 11 |
<script type="text/javascript"> |
| 12 |
var model; |
| 13 |
|
| 14 |
require([ |
| 15 |
'dojo/parser', |
| 16 |
'dojo/ready', |
| 17 |
'dojox/mvc', |
| 18 |
'dijit/form/TextBox', |
| 19 |
'dijit/form/Button', |
| 20 |
'dojox/mvc/Group', |
| 21 |
'dojox/mvc/Output' |
| 22 |
], function(parser, ready, mvc){ |
| 23 |
|
| 24 |
// Initial data |
| 25 |
var order = { |
| 26 |
"Serial" : "360324", |
| 27 |
"First" : "John", |
| 28 |
"Last" : "Doe", |
| 29 |
"Email" : "[email protected]", |
| 30 |
"ShipTo" : { |
| 31 |
"Street" : "123 Valley Rd", |
| 32 |
"City" : "Katonah", |
| 33 |
"State" : "NY", |
| 34 |
"Zip" : "10536" |
| 35 |
}, |
| 36 |
"BillTo" : { |
| 37 |
"Street" : "17 Skyline Dr", |
| 38 |
"City" : "Hawthorne", |
| 39 |
"State" : "NY", |
| 40 |
"Zip" : "10532" |
| 41 |
} |
| 42 |
}; |
| 43 |
// The dojox.mvc.StatefulModel class creates a data model instance |
| 44 |
// where each leaf within the data model is decorated with dojo.Stateful |
| 45 |
// properties that widgets can bind to and watch for their changes. |
| 46 |
model = mvc.newStatefulModel({ data : order }); |
| 47 |
// the StatefulModel created above is initialized with |
| 48 |
// model.First set to "John", model.Last set to "Doe" and model.Email set to "[email protected]" |
| 49 |
|
| 50 |
}); |
| 51 |
|
| 52 |
// setRef is call when the "Ship To" or "Bill To" button is pressed. |
| 53 |
function setRef(id, addrRef) { |
| 54 |
var widget = dijit.byId(id); |
| 55 |
widget.set("ref", addrRef); |
| 56 |
} |
| 57 |
</script> |
| 58 |
|
| 59 |
|
| 60 |
</head> |
| 61 |
<body class="claro"> |
| 62 |
<div id="wrapper"> |
| 63 |
<div id="header"> |
| 64 |
<div id="navigation"> |
| 65 |
</div> |
| 66 |
<div id="headerInsert"> |
| 67 |
<h1>Order Shipping Details</h1> |
| 68 |
<h2>Data Binding Example - Group Container.</h2> |
| 69 |
</div> |
| 70 |
</div> |
| 71 |
<div id="main"> |
| 72 |
<div id="leftNav"></div> |
| 73 |
<div id="mainContent"> |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
<div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'model'"> |
| 81 |
<div class="row"> |
| 82 |
<label class="cell" for="serialInput">Order #:</label> |
| 83 |
<input class="cell" id="serialInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Serial'"/> |
| 84 |
</div> |
| 85 |
<div class="row"> |
| 86 |
<label class="cell" for="lastnameInput">Last:</label> |
| 87 |
<input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"/> |
| 88 |
</div> |
| 89 |
<div class="row"> |
| 90 |
<label class="cell" for="emailInput">Email:</label> |
| 91 |
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"/> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
<br/> |
| 95 |
Choose: |
| 96 |
<button id="shipto" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setRef('addrGroup', model.ShipTo);}">Ship To</button> |
| 97 |
<button id="billto" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setRef('addrGroup', model.BillTo);}">Bill To</button> |
| 98 |
<br/> |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
<div class="row" id="addrGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'model.ShipTo'"> |
| 108 |
<div class="row"> |
| 109 |
<label class="cell" for="streetInput">Street:</label> |
| 110 |
<input class="cell" id="streetInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Street'"/> |
| 111 |
</div> |
| 112 |
<div class="row"> |
| 113 |
<label class="cell" for="cityInput">City:</label> |
| 114 |
<input class="cell" id="cityInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'City'"/> |
| 115 |
</div> |
| 116 |
<div class="row"> |
| 117 |
<label class="cell" for="stateInput">State:</label> |
| 118 |
<input class="cell" id="stateInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'State'"/> |
| 119 |
</div> |
| 120 |
<div class="row"> |
| 121 |
<label class="cell" for="zipInput">Zipcode:</label> |
| 122 |
<input class="cell" id="zipInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Zip'"/> |
| 123 |
</div> |
| 124 |
</div> |
| 125 |
<br/> |
| 126 |
Model: |
| 127 |
<button id="reset" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){model.reset();}">Reset</button> |
| 128 |
</div></div></div> |
| 129 |
</body> |
| 130 |
</html> |