💬 AppML Views and Messages
Estimated reading: 4 minutes 115 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 :
Share

AppML – View Update Mechanism

Or Copy Link

CONTENTS
Scroll to Top