Updated
This commit is contained in:
68
master/examples/generate.html
Normal file
68
master/examples/generate.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<div id="generate" class="view mblView">
|
||||
<h1 dojoType="dojox.mobile.Heading" back="Home">Simple Form Generate Example</h1>
|
||||
<div class="field-title"></div>
|
||||
<div id="main">
|
||||
<div id="leftNav">
|
||||
</div>
|
||||
<div id="mainContent" class="generate-maincontent">
|
||||
<div id="outerModelArea">
|
||||
<h3 dojoType="dojox.mobile.RoundRectCategory">Model</h3>
|
||||
<div class="generate-textarea-row">
|
||||
<textarea class="generate-textarea-cell" dojoType="dojox.mobile.TextArea" id="modelArea" style="width: 300px; height: 300px;">
|
||||
{
|
||||
"Serial": "11111",
|
||||
"First": "John",
|
||||
"Last": "Doe",
|
||||
"Email": "jdoe@example.com",
|
||||
"Phones": [
|
||||
{
|
||||
"Office": "111-111-1111"
|
||||
},
|
||||
{
|
||||
"Mobile": "222-222-2222"
|
||||
}
|
||||
]
|
||||
}
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="fieldset">
|
||||
<div class="spacer"></div>
|
||||
<button id="generate1" dojoType="dojox.mobile.Button" class="mblBlueButton" data-dojo-props="onClick: function(e){updateView();}">Generate Form</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="viewArea" style="display:none">
|
||||
<h3 dojoType="dojox.mobile.RoundRectCategory">Generated View</h3>
|
||||
<div class="fieldset">
|
||||
<div id="view" dojoType="dojox.mvc.Generate"></div>
|
||||
</div>
|
||||
<div class="fieldset">
|
||||
<div class="spacer"></div>
|
||||
<button id="updateModel" dojoType="dojox.mobile.Button" class="mblBlueButton" data-dojo-props="onClick: function(e){updateModel();}">Update Model</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// used in the Generate View demo
|
||||
var genmodel;
|
||||
function updateView() {
|
||||
try {
|
||||
var modeldata = dojo.fromJson(dojo.byId("modelArea").value);
|
||||
genmodel = dojox.mvc.newStatefulModel({ data : modeldata });
|
||||
dijit.byId("view").set("ref", genmodel);
|
||||
dojo.byId("outerModelArea").style.display = "none";
|
||||
dojo.byId("viewArea").style.display = "";
|
||||
}catch(err){
|
||||
console.error("Error parsing json from model: "+err);
|
||||
}
|
||||
};
|
||||
|
||||
// used in the Generate View demo
|
||||
function updateModel() {
|
||||
dojo.byId("modelArea").focus(); // hack: do this to force focus off of the textbox, bug on mobile?
|
||||
dojo.byId("viewArea").style.display = "none";
|
||||
dojo.byId("outerModelArea").style.display = "";
|
||||
dijit.byId("modelArea").set("value",(dojo.toJson(genmodel.toPlainObject(), true)));
|
||||
};
|
||||
</script>
|
||||
</div>
|
||||
Reference in New Issue
Block a user