πŸ’‘ AppML Advanced Topics
Estimated reading: 4 minutes 39 views

πŸ”„ AppML – Dynamic Updates Without Page Refresh: Create Live Data Apps in Pure HTML

🧲 Introduction – Why Use Dynamic Updates in AppML?

In modern web development, users expect real-time updatesβ€”like adding new data, filtering items, or updating a recordβ€”without refreshing the page. With AppML, you can build this functionality using simple HTML, JSON models, and the appml-data attributeβ€”no JavaScript frameworks required.

🎯 In this guide, you’ll learn:

  • How AppML updates content dynamically
  • How to use appml-submit for live form updates
  • How to insert, update, and filter data on the fly
  • Real-world examples with code and step-by-step explanations

βš™οΈ How AppML Enables Dynamic Behavior

AppML uses AJAX behind the scenes. When you:

  • Submit a form (appml-submit)
  • Load data from a model (appml-data)
  • Update a record (appml-key)
  • Filter data dynamically (appml-filter)

…it reloads only the affected part of the page, not the whole document.


πŸ§ͺ Example 1 – Add Data Without Refresh

Let’s build a simple contact list. Users can submit the form, and the list updates instantly.

βœ… contacts-model.json

{
  "table": "contacts",
  "key": "id",
  "fields": [
    { "name": "name", "required": true },
    { "name": "email", "required": true }
  ]
}

βœ… save-contact.php

<?php
include("appml.php");

$appml = new AppML();
$appml->model = "contacts-model.json";
$appml->run();
?>

βœ… HTML Form + Live List

<!-- Form -->
<div 
  appml-model="contacts-model.json" 
  appml-data="save-contact.php" 
  appml-message>

  <h3>Add Contact</h3>
  <input name="name" placeholder="Name">
  <input name="email" placeholder="Email">
  <button appml-submit>Save</button>
</div>

<!-- Live Contact List -->
<div 
  appml-model="contacts-model.json" 
  appml-data="save-contact.php">

  <h3>Contact List</h3>
  <p>{{name}} – {{email}}</p>
</div>

πŸ” Code Explanation

CodePurpose
appml-submitSends the form data using AJAX
appml-data="save-contact.php"Backend PHP file that saves and returns JSON
appml-messageDisplays success/error messages
Second <div>Automatically updates with new contact data after saving

βœ”οΈ When the form is submitted, the data is added to the server and the list updatesβ€”without reloading the page.


πŸ§ͺ Example 2 – Inline Record Update

You can also edit a specific record dynamically using appml-key.

<div 
  appml-model="contacts-model.json" 
  appml-data="save-contact.php" 
  appml-key="3"
  appml-message>

  <h3>Edit Contact</h3>
  <input name="name">
  <input name="email">
  <button appml-submit>Update</button>
</div>

πŸ” Explanation:

  • appml-key="3": Loads the record with ID 3.
  • Fields are pre-filled from the database.
  • When submitted, the update is sent without refreshing the page.

πŸ§ͺ Example 3 – Filter/Search Without Reload

You can also create live search filters.

<input 
  appml-filter="name" 
  placeholder="Search by name">

<div 
  appml-model="contacts-model.json" 
  appml-data="save-contact.php">

  <p>{{name}} – {{email}}</p>
</div>

πŸ” Explanation:

  • The input filters the contact list as the user types.
  • appml-filter="name" applies a client-side filter on the name field.
  • No backend or page reload required.

πŸ’‘ Best Practices for Dynamic Updates in AppML

TipWhy It Helps
βœ… Use appml-messageGet instant feedback without alerts
βœ… Split logic into componentsSeparate forms and lists for clarity
βœ… Use appml-key smartlyPre-fill forms for updates easily
βœ… Keep models consistentEnsure fields in JSON match input names

πŸ“Œ Summary – Recap & Key Takeaways

AppML makes real-time UI updates easy without JavaScript frameworks. Using appml-submit, appml-data, and appml-filter, you can build responsive apps that update dynamically and instantly.

πŸ” Key Takeaways:

  • Submit and save data using appml-submit + appml-data
  • Reload views instantly without refreshing the page
  • Use appml-key to edit data live
  • Use appml-filter to search/filter lists in real-time

βš™οΈ AppML empowers developers to build dynamic, fast interfaces with just HTML and JSON.


❓ FAQs – Dynamic Behavior in AppML


❓ How does AppML update without page reload?
βœ… It uses AJAX behind the scenes to fetch and re-render only affected HTML.


❓ Can I update multiple views at once?
βœ… Yes, but each view must be in its own div with separate appml-model.


❓ Does AppML support real-time push (WebSocket)?
❌ No. AppML uses pull-based AJAX, not real-time sockets.


❓ Can I customize the message shown after a save?
βœ… Yes, via myAppML.message in a controller or using server response.


❓ Is page refresh ever needed in AppML apps?
❌ No, unless you’re performing a full app reload. AppML handles partial updates natively.


Share Now :

Leave a Reply

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

Share

AppML – Dynamic Updates without Refresh

Or Copy Link

CONTENTS
Scroll to Top