dojox
Version:
Dojo eXtensions, a rollup of many useful sub-projects and varying states of maturity – from very stable and robust, to alpha and experimental. See individual projects contain README files for details.
152 lines (139 loc) • 5.58 kB
HTML
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Static Master/Detail Pattern -- Multiple Address Detail example</title>
<script src="../../../dojo/dojo.js"
type="text/javascript"
data-dojo-config="parseOnLoad: false, isDebug: true, mvc: {debugBindings: true}">
</script>
<style type="text/css">
@import "css/app-format.css";
@import "../../../dijit/themes/claro/claro.css";
</style>
<script type="text/javascript" >
var model1, model1Data, model2Data, model3Data;
require([
'dojo/parser',
"dojo/_base/lang",
'dojo/ready',
'dojo/when',
"dojo/Stateful",
"dojox/mvc/getStateful",
"dojox/mvc/getPlainValue",
"dojox/mvc/EditModelRefController",
"dojo/store/Memory",
'dijit/registry',
'dijit/form/TextBox',
'dijit/form/Button',
'dojox/mvc/Group',
'dojox/mvc/Repeat',
'dojox/mvc/Output'
], function(parser, lang, ready, when, Stateful, getStateful, getPlainValue, EditModelRefController, Memory, registry){
model1Data =
[{
"Query" : "Engineers1",
"First" : "Anne1",
"Last" : "Ackerman1"
}];
model2Data =
[{
"Query" : "Engineers2",
"First" : "Anne2",
"Last" : "Ackerman2"
}];
model3Data =
[{
"Query" : "Engineers3",
"First" : "",
"Last" : ""
}];
//var memStore1 = new dojo.store.Memory({data : model1Data});
//var model1 = dojox.mvc.newStatefulModel({ store : memStore1 })[0];
var memStore1 = new Memory({data : model1Data});
when(memStore1.query(), function(data){
model1 = EditModelRefController({sourceModel : new Stateful({current: getStateful(data)[0]})});
vfaModel = new Stateful();
vfaModel.set('session', new Stateful());
vfaModel.session.set("user","FirstUser");
});
replaceData = function(dest, src){
src = getPlainValue(src);
dest.set("current", getStateful(src));
};
// when "dojo/ready" is ready call parser.parse
ready(function(){
parser.parse();
});
});
</script>
</head>
<body class="claro">
<script type="dojo/require">at: "dojox/mvc/at"</script>
<script type="dojo/require">Stateful: "dojo/Stateful"</script>
<div id="wrapper">
<div id="header">
<div id="navigation"></div>
<div id="headerInsert">
<h1>Input Output Sync</h1>
<h2>Data Binding Example</h2>
</div>
</div>
<div id="main">
<div id="leftNav"></div>
<div id="mainContent">
<h4>Replace Model 1 data with original data from the models listed below, this should keep the bindings to the Model1 Output</h4>
<div class="row" style="width: 740px">
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){replaceData(model1, model1Data[0]);}">Replace with Orig. Model1 data</button>
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){replaceData(model1, model2Data[0]);}">Replace with Orig. Model2 data</button>
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){replaceData(model1, model3Data[0]);}">Replace with Orig. Model3 data</button>
</div>
<div id="outergroupId1x" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(model1, 'current')">
<div class="row">
<label class="cell" for="nameInput${this.index}">Name:</label>
<input class="cell" data-dojo-type="dijit.form.TextBox" id="fnameInput"
data-dojo-props="value: at('rel:', 'First')">
</div>
<div class="row">
<label class="cell" for="nameInput${this.index}">Name:</label>
<input class="cell" data-dojo-type="dijit.form.TextBox" id="lnameInput"
data-dojo-props="value: at('rel:', 'Last')">
</div>
<div class="row">
<label class="cell" for="nameInput${this.index}">Name:</label>
<input class="cell" data-dojo-type="dijit.form.TextBox" id="qnameInput"
data-dojo-props="value: at('rel:', 'Query')">
</div>
</div>
<div class="row" id="outputgroupId" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(model1, 'current')">
<span>
Model1 Output is ==>
</span>
<span id="firstnameOutput10" data-dojo-type="dojox.mvc.Output"
data-dojo-props="value: at('rel:', 'First')">
Name1 is "${this.value}" :
</span>
<span id="firstnameOutput11" data-dojo-type="dojox.mvc.Output"
data-dojo-props="value: at('rel:', 'Last')">
Name2 is "${this.value}" :
</span>
<span id="firstnameOutput12" data-dojo-type="dojox.mvc.Output"
data-dojo-props="value: at('rel:', 'Query')">
Name3 is "${this.value}"
</span>
</div>
<br/>Model:
<button id="reset" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){model1.reset();}">Reset all</button>
<div id="outergroupId2x" data-dojo-type="dojox.mvc.Group" data-dojo-props="target: at(vfaModel, 'session')">
<div class="row">
<label class="cell" for="configurationId">Session:</label>
<input class="cell" data-dojo-type="dijit.form.TextBox" id="configurationId"
data-dojo-props="value: at('rel:', 'user')">
</div>
<button id="resetses" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){vfaModel.set('session', new Stateful());}">Reset session</button>
</div>
</div>
</div>
</div>
</body>
</html>