Skip to content

jquery plugin to simplify autosaving a form: periodic, window.onbeforeunload, elements.onclick

Notifications You must be signed in to change notification settings

ulihecht/jquery-autosaveform

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

jQuery AutoSaveForm

NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.

USAGE: setting up any number of forms, default options

$("#my-container form").autoSaveForm();

USAGE: setting up one form by ID, custom options

$("#MyForm").autoSaveForm({
	autosave_frequency: 0, 										# autosave disabled
	autosave_onclick: "#my-container a[href]:not([rel])",		# custom links to be bound as autosavefirst
	form_inputs: "select",										# only considering selects in the form
	attr_data: "data-ASFcustom-serialize",						# customize internal attributes for forms' data
	attr_status: "data-ASFcustom-status",						# customize internal attributes for forms' status
	form_response_regex: "Saved"								# save response must contain: Saved
	form_action: "/myform/submit.php"							# over-ride the submit action for the form (edge case)
	});

EXTRA: bind event handlers for callbacks

$("#MyForm").autoSaveForm({
	form_response_regex: "Saved"
}).bind("autosave_complete", function() {
	pageTracker._trackEvent("ajax", "autoSaveForm", window.location.href, $(this).attr("action"));
}).bind("autosave_error", function() {
	pageTracker._trackEvent("ajax", "autoSaveFormERROR", window.location.href, $(this).attr("action"));
});

EXTRA CONFIGURATIONS

$.fn.ASF_beforeunload = false; 									# disable onbeforeunload functionality
$.fn.ASF_beforeunload_message = "are you sure?";				# custom message before unload (if we need to prompt)
$.fn.ASF_debug = true;											# turn on debug messages in console

About

jquery plugin to simplify autosaving a form: periodic, window.onbeforeunload, elements.onclick

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published