new RemanentForm(url, slug, index, save_callback, load_classback)
- Description:
Defines a remamence mechanism for a HTML form.
- This mechanism allows a HTML form data to be remament, i.e., saved and reloaded, using the construct:
<script type='text/javascript' src='.../aideweb.js'></script> <script>var remanentForm = new RemanentForm("$url", "$slug", "$index", save_callback, load_callback);</script> <!--- where $slug, $index are user choosen names, $url is the persistant data service url --> <form id='$slug'> <input name='$index' type='text' required/> <a onclick='remanentForm.load("$slug")'>Load the data</a> <!--- other form input ---> <input type='submit'>Save the data</input> </form>
- On submit, the form data is stored in a $slug-$index.value JSON file via the persistant data service.
- When remanentFormLoad is called, the data, if predefined, is loaded.
- The form data can also be preloaded by providing the values in the url query.
- Here we do NOT want the input data to be treated by a action='' attribute since it is managed via this mechanism. Remark:
- The present mechanism is designed for any textual (e.g., 'text'), 'radio', and 'checkbox' input type, only.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | The persistant data service URL. |
slug |
string | The form ID, also used as the form JSON file prefix. |
index |
string | The form 'index' input name (e.g., user email), used as unique identifier of the form data. |
save_callback |
callback | Callback function called when the data is saved.
|
load_classback |
callback | Callback function called when the data is loaded.
|
Methods
load(slug)
- Description:
Preloads the data in the remamence mechanism for a HTML form.
Parameters:
Name | Type | Description |
---|---|---|
slug |
string | The form ID, also used as the form JSON file prefix. |