Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README.textile
Octocat-spinner-32 jquery.autosaveform.js
README.textile

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
Something went wrong with that request. Please try again.