| 1 |
define(["dojo/dom", "dojo/_base/connect", "dijit/registry"], |
| 2 |
function(dom, connect, registry){ |
| 3 |
|
| 4 |
var _connectResults = []; |
| 5 |
var currentModel = null; |
| 6 |
|
| 7 |
var setFromModel = function (){ |
| 8 |
registry.byId("firstInput1").set('value', currentModel[0].First); |
| 9 |
registry.byId("lastInput1").set('value', currentModel[0].Last); |
| 10 |
registry.byId("emailInput1").set('value', currentModel[0].Email); |
| 11 |
registry.byId("shiptostreetInput1").set('value', currentModel[0].ShipTo.Street); |
| 12 |
registry.byId("shiptocityInput1").set('value', currentModel[0].ShipTo.City); |
| 13 |
registry.byId("shiptostateInput1").set('value', currentModel[0].ShipTo.State); |
| 14 |
registry.byId("shiptozipInput1").set('value', currentModel[0].ShipTo.Zip); |
| 15 |
registry.byId("billtostreetInput1").set('value', currentModel[0].BillTo.Street); |
| 16 |
registry.byId("billtocityInput1").set('value', currentModel[0].BillTo.City); |
| 17 |
registry.byId("billtostateInput1").set('value', currentModel[0].BillTo.State); |
| 18 |
registry.byId("billtozipInput1").set('value', currentModel[0].BillTo.Zip); |
| 19 |
}; |
| 20 |
|
| 21 |
return { |
| 22 |
|
| 23 |
init: function(){ |
| 24 |
currentModel = this.loadedModels.names; |
| 25 |
var connectResult; |
| 26 |
|
| 27 |
connectResult = connect.connect(dom.byId('shipto'), "click", function(){ |
| 28 |
|
| 29 |
dom.byId("billtodiv").style.display = "none"; |
| 30 |
dom.byId("shiptodiv").style.display = ""; |
| 31 |
}); |
| 32 |
_connectResults.push(connectResult); |
| 33 |
|
| 34 |
connectResult = connect.connect(dom.byId('billto'), "click", function(){ |
| 35 |
|
| 36 |
dom.byId("billtodiv").style.display = ""; |
| 37 |
dom.byId("shiptodiv").style.display = "none"; |
| 38 |
}); |
| 39 |
_connectResults.push(connectResult); |
| 40 |
|
| 41 |
connectResult = connect.connect(dom.byId('reset1'), "click", function(){ |
| 42 |
|
| 43 |
setFromModel(); |
| 44 |
|
| 45 |
}); |
| 46 |
_connectResults.push(connectResult); |
| 47 |
|
| 48 |
dom.byId("billtodiv").style.display = "none"; |
| 49 |
setFromModel(); |
| 50 |
|
| 51 |
}, |
| 52 |
|
| 53 |
|
| 54 |
destroy: function(){ |
| 55 |
var connectResult = _connectResults.pop(); |
| 56 |
while(connectResult){ |
| 57 |
connect.disconnect(connectResult); |
| 58 |
connectResult = _connectResults.pop(); |
| 59 |
} |
| 60 |
} |
| 61 |
}; |
| 62 |
}); |