Archive for December, 2011

jQuery Method To Prompt A User To Save Changes Before Leaving Page

var isDirty = false;

$(‘:input’).change(function(){
if(!isDirty){
isDirty = true;
}
});

$(‘a’).click(function(){
if(isDirty){
var confirmExit = confirm(‘Are you sure? You haven\’t saved your changes. Click OK to leave or Cancel to go back and save your changes.’);
if(confirmExit){
return true;
}
else{
return false;
}
}
});

ref : http://cfsilence.com/blog/client/index.cfm/2009/10/12/jQuery-Method-To-Prompt-A-User-To-Save-Changes-Before-Leaving-Page

Advertisements

Leave a comment