πŸ’¬ AppML Views and Messages
Estimated reading: 4 minutes 29 views

πŸ”„ 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 setTriggers filtered rendering
Form submissions (appml-submit)Updates data and refreshes the list or form
Changing the value of inputsAuto-updates form state
appml-include updatesRefreshes 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:

  1. Fetches the data (JSON/XML)
  2. Loops through records
  3. Replaces all {{ }} bindings
  4. 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 boxSets filter + calls load()
Clicking sort buttonsSets sort + calls load()
Submitting a formUpdates data + refreshes bound list
Changing form field with defaultTriggers re-validation
Switching controller at runtimeApplies 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 :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

AppML – View Update Mechanism

Or Copy Link

CONTENTS
Scroll to Top