أدوات تحكم AppML
الغرض من وحدة تحكم AppML ، هو السماح لك بالتحكم في تطبيقك.
ما الذي يمكن أن تفعله وحدة التحكم؟
- اضبط البيانات الأولية
- تغيير بيانات التطبيق
- التعامل مع المدخلات والمخرجات
- تحقق من صحة البيانات
- لخص البيانات
- معالجة الأخطاء
- بدء التطبيقات وإيقافها
- وأكثر بكثير
بدون جهاز تحكم
بشكل افتراضي ، تعمل تطبيقات AppML بدون وحدة تحكم:
مثال
<table appml-data="customers.js">
<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>
مع وحدة تحكم
باستخدام وحدة تحكم AppML ، يمكنك التحكم في تطبيقك باستخدام JavaScript .
وحدة التحكم هي وظيفة JavaScript توفرها أنت .
يتم استخدام السمة appml-controller للإشارة إلى وظيفة وحدة التحكم.
مثال
<h1>Customers</h1>
<table appml-data="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>
تقوم وحدة التحكم (myController) في المثال أعلاه بتغيير قيمة "CustomerName" إلى أحرف كبيرة ، قبل عرضها.
إذا كانت لديك وحدة تحكم ، فسيرسل AppML كائن التطبيق ($ appml) إلى وحدة التحكم ، لكل إجراء مهم.
إحدى خصائص التطبيق هي الرسالة (appml.message $) ، التي تصف حالة التطبيق.
Message | Description |
---|---|
ready | Sent after AppML is initiated, and ready to load data. |
loaded | Sent after AppML is fully loaded, ready to display data. |
display | Sent before AppML displays a data item. |
done | Sent after AppML is done (finished displaying). |
submit | Sent before AppML submits data. |
error | Sent after AppML has encountered an error. |
يتم شرح الرسائل في الفصل التالي.