Plugins: fleegix.form.diff
Allows you to restore a form from a serialized representation of its fields.
Download fleegix.form.restore (2.5KB)
fleegix.form.restore
Syntax
fleegix.form.restore(formElement, serializedString);
Parameters
formElement (Object) -- The HTML form you want to restore from a string.
serializedString (String) -- The query-string-style string of serialized form data you want to use to restore the form-element values.
Description
Allows you to restore a blank form to the state it was in when it was serialized to a string. This can be nice if you don't want to fill your server-side code with a bunch of conditionals to pre-fill a form from values in the database.
Examples
function getDataAndRestore(userId) {
fleegix.xhr.doGet(doRestore,
'/get_user_settings.rbx?userId=' + userId);
}
function doRestore(str) {
var settingsForm = document.getElementById('settingsForm');
fleegix.form.restore(settingsForm, str);
}
getDataAndRestore();
=> Pulls the original serialized form data used to save the
user settings, and uses them to pre-fill the form