You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.0 KiB
84 lines
3.0 KiB
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
|
<title>Simple Input-Output Data Binding Example</title> |
|
<style type="text/css"> |
|
@import "css/app-format.css"; |
|
@import "../../../dijit/themes/claro/claro.css"; |
|
</style> |
|
|
|
<script type="text/javascript" data-dojo-config="parseOnLoad:0,isDebug:1,async:1,mvc:{debugBindings:1}" |
|
src="../../../dojo/dojo.js"></script> |
|
<script type="text/javascript"> |
|
var model; |
|
|
|
require([ |
|
'dojo/parser', |
|
'dojo/ready', |
|
'dojox/mvc', |
|
'dijit/form/TextBox', |
|
'dijit/form/Button', |
|
'dojox/mvc/Group', |
|
'dojox/mvc/Output' |
|
], function(parser, ready, mvc){ |
|
|
|
// The dojox.mvc.StatefulModel class creates a data model instance |
|
// where each leaf within the data model is decorated with dojo.Stateful |
|
// properties that widgets can bind to and watch for their changes. |
|
model = mvc.newStatefulModel({ data : { "First" : "John", "Last" : "Doe", "Email" : "jdoe@example.com" }}); |
|
// the StatefulModel created above is initialized with |
|
// model.First set to "John", model.Last set to "Doe" and model.Email set to "jdoe@example.com" |
|
|
|
// 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> |
|
<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"> |
|
<div class="row"> |
|
<label class="cell" for="firstnameInput">First:</label> |
|
<input class="cell" id="firstnameInput" data-dojo-type="dijit.form.TextBox" |
|
data-dojo-props="value: at(model.First, 'value')"></input> |
|
<!-- Content in output below will always be in sync with value of textbox above --> |
|
<span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model.First, 'value')"> |
|
(first name is: ${this.value}) |
|
</span> |
|
</div> |
|
<div class="row"> |
|
<label class="cell" for="lastnameInput">Last:</label> |
|
<input class="cell" id="lastnameInput" data-dojo-type="dijit.form.TextBox" |
|
data-dojo-props="value: at(model.Last, 'value')"></input> |
|
<span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model.Last, 'value')"> |
|
(last name is: ${this.value}) |
|
</span> |
|
</div> |
|
<div class="row"> |
|
<label class="cell" for="emailInput">Email:</label> |
|
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" |
|
data-dojo-props="value: at(model.Email, 'value')"></input> |
|
<span data-dojo-type="dojox.mvc.Output" data-dojo-props="value: at(model.Email, 'value')"> |
|
(email is: ${this.value}) |
|
</span> |
|
</div> |
|
<br/>Model: |
|
<button id="reset" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){model.reset();}">Reset</button> |
|
</div> |
|
</div> |
|
</div> |
|
</body> |
|
</html>
|
|
|