π AppML β View Update Mechanism: How AppML Keeps Your Data in Sync
π§² Introduction β Why Understanding View Updates Is Crucial
In dynamic applications, keeping the UI in sync with underlying data is key to great user experience. AppMLβs view update mechanism ensures that whenever your data changesβthrough filters, input, or API responsesβthe HTML is automatically re-rendered without manual intervention or JavaScript frameworks.
π― In this guide, youβll learn:
- How AppML updates the view automatically
- Events and triggers that cause a view update
- Real-time examples: filtering, sorting, and input-driven updates
- Best practices to ensure smooth and reactive UI behavior
βοΈ How AppML Updates Views Automatically
AppML uses a combination of declarative bindings ({{field}}
) and reactive triggers to detect when data has changed. It then refreshes the HTML view bound by appml-data
, appml-model
, or appml-controller
.
π Trigger Points for View Updates:
π§© Trigger | π Description |
---|---|
myAppML.load() | Reloads data and re-renders the view |
filter or sqlfilter set | Triggers filtered rendering |
Form submissions (appml-submit ) | Updates data and refreshes the list or form |
Changing the value of inputs | Auto-updates form state |
appml-include updates | Refreshes included templates during load |
π§ͺ Basic Example β Triggering an Update with myAppML.load()
<input onkeyup="search(this.value)" placeholder="Search by name">
<div appml-data="data/users.json" appml-controller="user-controller.js">
<p>{{name}}</p>
</div>
β
user-controller.js
function search(value) {
myAppML.filter = "name LIKE '*" + value + "*'";
myAppML.load();
}
β Whenever the user types, the view reloads with matching results.
π Partial Updates vs Full Reloads
β
myAppML.load()
- Refreshes only the current AppML block
- Does not reload the entire page
- Keeps things efficient and responsive
β Automatic on Submit
<button appml-submit>Save</button>
- Automatically triggers data refresh after form submission
- Useful for forms that display updated lists post-submission
π§ How Data Binding Works Internally
When AppML parses a block like this:
<p>{{name}} β {{email}}</p>
It creates a template clone and replaces {{name}}
and {{email}}
with values from the current dataset. Each time myAppML.load()
runs, AppML:
- Fetches the data (JSON/XML)
- Loops through records
- Replaces all
{{ }}
bindings - Injects the new HTML into the DOM
π‘ Dynamic Filtering + Reload = Real-Time UI
myAppML.onshow = function() {
myAppML.filter = "status='active'";
myAppML.sort = "name";
};
Combined with:
myAppML.load(); // View gets updated instantly
β This logic dynamically filters the list and updates the view with the new results.
π§ Real-Time View Update Use Cases
π‘ Scenario | π How It Updates |
---|---|
Typing in a search box | Sets filter + calls load() |
Clicking sort buttons | Sets sort + calls load() |
Submitting a form | Updates data + refreshes bound list |
Changing form field with default | Triggers re-validation |
Switching controller at runtime | Applies new logic + refreshes UI |
π Summary β Recap & Key Takeaways
AppML automatically keeps your UI synced with your data model. Whether you’re filtering lists, updating forms, or working with dynamic includes, the view update mechanism ensures your changes reflect instantly on screenβno JavaScript frameworks needed.
π Key Takeaways:
- Use
myAppML.load()
to manually refresh the view - Filters, sorting, and controllers auto-trigger updates
{{ }}
placeholders are recompiled with fresh data- Use declarative HTML for form inputs and auto-updates
- Efficient DOM updates make your UI feel dynamic and fast
βοΈ AppMLβs reactivity keeps your interface lightweight yet powerfulβideal for admin panels, dashboards, and low-code platforms.
β FAQs β AppML View Update Mechanism
β When should I call myAppML.load()
manually?
β
When applying dynamic filters, changes from user input, or after modifying controller logic.
β Does AppML auto-refresh on form submission?
β
Yes. When you use appml-submit
, AppML re-fetches and re-renders the view.
β What if my data is remote (e.g., API)?
β
AppML treats remote data like any other source. Just point appml-data
to the URL, and call load()
when needed.
β Can I update only a portion of the view?
β οΈ AppML reloads the full appml-data
blockβnot individual items. Structure your UI into blocks for partial updates.
β Is the view refreshed if the backend returns an empty list?
β
Yes. AppML clears the block and shows nothingβno errorβunless you add custom messages.
Share Now :