最新的Web開發教程
 

AppML案例分析 - 托運人


HTML頁面

這是HTML源代碼:

<!DOCTYPE html>
<html lang="en-US">
<title>Shippers</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://www.w3ii.com/appml/2.0.3/appml.js"></script>
<body>

<div class="container">
<h1>Shippers</h1>

<div id="Form01" class="jumbotron" style="display:none" appml-data="local?model=model_shippersform" appml-controller="myFormController">
<div appml-include-html="inc_formcommands.htm"></div>
<div class="form-group">
<label>ShipperName:</label>
<input id="ShipperName" class="form-control">
</div>
<div class="form-group">
<label>Phone:</label>
<input id="Phone" class="form-control">
</div>
</div>

<div appml-data="local?model=model_shipperslist">
  <div appml-include-html="inc_listcommands_nofilter.htm"></div>
  <table class="table table-striped table-bordered">
  <tr>
    <th></th>
    <th>Shipper</th>
    <th>Phone</th>
  </tr>
  <tr appml-repeat="records">
    <td style="cursor:pointer"
    onclick="appml('Form01').run({{ShipperID}})">
    <span class="glyphicon glyphicon-edit"></span>
    </td>
    <td>{{ShipperName}}</td>
    <td>{{Phone}}</td>
  </tr>
  </table>
</div>

</div>

<script>
function myFormController($appml) {
    if ($appml.message == "ready") {return -1;}
    if ($appml.message == "loaded") {
        document.getElementById("Form01").style.display = "";
    }
}
</script>

</body>
</html>
PHP» .NET»

楷模

這些是在應用程序中使用的模型:

列表模型

{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Shippers"
}
}

形模型

{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Shippers",
"maintable" : "Shippers",
"keyfield" : "ShipperID"
},
"updateItems" : [
{"item" : "ShipperName"},
{"item" : "Phone"}
]
}