Files
openlayers/master/examples/test_async-mvc_input-output-simple.html
Éric Lemoine 5d14b9e2d4 Updated
2013-02-20 10:38:25 +01:00

83 lines
2.9 KiB
HTML

<!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" djConfig="parseOnLoad:0,isDebug:1,async: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">
<div id="wrapper">
<div id="header">
<div id="navigation"></div>
<div id="headerInsert">
<h1>Input Ouput 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="ref: model.First"></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="ref: model.First">
(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="ref: model.Last"></input>
<span data-dojo-type="dojox.mvc.Output" data-dojo-props="ref: model.Last">
(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="ref: model.Email"></input>
<span data-dojo-type="dojox.mvc.Output" data-dojo-props="ref: model.Email">
(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>