UNPKG

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.

85 lines (83 loc) 3.42 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>Static Master/Detail Pattern -- Multiple Address Detail example</title> <style type="text/css"> @import "css/app-format.css"; @import "../../../../dijit/themes/claro/claro.css"; .row { width: 500px; display: inline-block; margin: 5px; } .cell { width: 20%; display:inline-block; } .textcell { width: 30%; display:inline-block; } </style> <script type="text/javascript" djConfig="parseOnLoad:1,isDebug:1,async:1" src="../../../../dojo/dojo.js"></script> <script type="text/javascript"> var model; require([ 'dojo/parser', 'dojox/mvc', 'dijit/form/TextBox', 'dijit/form/Button', 'dojox/mvc/Group', 'dojox/mvc/Output' ], function(parser, 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" }); </script> </head> <body class="claro"> <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="firstId">First:</label> <input class="textcell" id="firstId" 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="textcell" 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="textcell" 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> <button id="fromModel" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){model.First.set('value','Updated in Model');}">Update First from Model</button> <button id="fromWidget" type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){dijit.byId('firstId').set('value','Updated Widget');}">Update First from Widget</button> </div> </div> </div> </body> </html>