AppML 参考引用
AppML HTML 属性
实例
<!DOCTYPE html><html><title>Customers</title><link rel="stylesheet" href="/example/appml/style.css"><script src="https://cankaoshouce.com/js/appml/appml.js"></script><body><div appml-include-html="/example/appml/inc_header.html"></div><h2>Customers</h2><table appml-data="/example/appml/customers.js" appml-controller="myController"><tr><th>Customer</th><th>City</th><th>Country</th></tr><tr appml-repeat="records"><td>{{CustomerName}}</td><td>{{City}}</td><td>{{Country}}</td></tr></table><div appml-include-html="/example/appml/inc_footer.html"></div><script>function myController($appml) {}</script></body></html>
| 属性 | 描述 | 解释 |
|---|---|---|
| appml-controller | 定义一个 AppML 控制器 | AppML 控制器 |
| appml-data | 定义应用程序的数据源 | AppML 数据 |
| appml-include-html | 定义如何包含 HTML | AppML 包含 HTML |
| appml-repeat | 定义要重复的 HTML 元素 | AppML 如何使用 |
AppML 消息
实例
<!DOCTYPE html><html><title>Customers</title><link rel="stylesheet" href="/example/appml/style.css"><script src="https://cankaoshouce.com/js/appml/appml.js"></script><body><h2>Customers</h2><table appml-data="/example/appml/customers.js" appml-controller="myController"><tr><th>Customer</th><th>City</th><th>Country</th></tr><tr appml-repeat="records"><td>{{CustomerName}}</td><td>{{City}}</td><td>{{Country}}</td></tr></table><script>function myController($appml) {if ($appml.message == "display") {if ($appml.display.name == "CustomerName") {$appml.display.value = $appml.display.value.toUpperCase();}}}</script></body></html>
| 消息 | 发送 |
|---|---|
| ready | 启动 AppML 并准备加载数据后。 |
| loaded | AppML 完全加载后,准备显示数据。 |
| display | 在 AppML 显示数据项之前。 |
| done | AppML 完成后(完成显示)。 |
| submit | 在 AppML 提交数据之前。 |
| error | AppML 遇到错误后。 |
更多关于 AppML 消息 的知识请访问 AppML 消息。
AppML 模型
实例
{"security": "admin","rowsperpage" : 10,"database": {"connection": "mysql","sql" : "SELECT * FROM Customers","orderby" : "CustomerName"}},"filteritems" : [{"item" : "CustomerName", "label" : "Customer"},{"item" : "City"},{"item" : "Country"}],"sortitems" : [{"item" : "CustomerName", "label" : "Customer"},{"item" : "City"},{"item" : "Country"}]}
AppML 模型属性
| 元素 | 描述 |
|---|---|
| "data" | 定义模型的文件源 |
| "database" | 定义模型的数据库源 |
| "filteritems" | 定义筛过滤器限制 |
| "rowsperpage" | 定义每页要获取的行数 |
| "security" | 定义模型的安全性 |
| "sortitems" | 定义排序限制 |
应用程序安全性
您必须以 "管理员" 组成员的身份登录才能访问此应用程序:
实例
{"security": "admin","database": {"connection": "mysql","sql" : "SELECT * FROM Customers","orderby" : "CustomerName"}}
私有模型
您可以将自己的私有数据添加到模型中。
这个例子表明了对数据的限制:
实例
"restrictions" : {"fname" : {"maxlength": 40},"price" : {"max": 999,"min": 100}}
服务器应用程序和 AppML 控制器可以使用模型数据。
本例使用模型数据验证输入:
实例
function myController($appml) {if ($appml.message == "submit") {var price = document.getElementById("price").value;if (price < $appml.model.restrictions.price.min) {$appml.displayError(15, "Price too low!");return;}}