My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

What it is

When a user enters data into a form, it can get lost if he leaves the page or clicks a link (be it ajax or not). Here comes protectData, it asks the user before losing his data by loading another page or submitting an ajax request(optional).

It integrates with jquery.form (so ajaxSubmit and ajaxForm are saved too).

(There is a typo in the current version(thx to timothy) loose vs lose, will be fixed in 0.2)

Examples

//basic protection
$('form').protectData(); 

//basic and ajax protection
$('form').protectData();
$.protectData.protectAjax = true;

//changing defaults
$.protectData.message = "You will lose data if continuing"; //change default message
$.protectData.stateChangeCallback = function(isProtected){alert('data was changed')};

//making 2 requests, without being notified
$('form').protectData();
$.protectData.protectAjax=true;
$('form input').change();

$.protectData.unprotectAjax(2);
$.get('file.txt');
$.get('file.txt');
$('form').load('nextform.html')//user will be asked before doing this

//data was saved using a non-standard way(submit / ajaxSubmit / ajaxForm are integrated)
$.protectData.unprotect()

Demo and Testsuite

Download package Test and Download (see right sidebar)

Life site

At the moment only used for intranet applications. Please send me a link to your site if you use it.

Works with

Tested with: IE6 IE7 FF2 FF3 Opera

Opera does not support onbeforeunload (explanation) so you will not get a message when leaving the page

Powered by Google Project Hosting