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

68 lines
3.0 KiB
HTML

<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>