Fixed #4415 Show a prompt when user navigates away from insert page without saving

Signed-off-by: Shivam Dixit <shivamd001@gmail.com>
This commit is contained in:
Shivam Dixit 2014-06-01 17:22:24 +05:30
parent e5367c1c40
commit 750f3d5f51

View File

@ -237,6 +237,8 @@ function verificationsAfterFieldChange(urlField, multi_edit, theType)
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('tbl_change.js', function () {
$("a").die('click');
$("form#insertForm :input:not([type=hidden])").unbind('change');
$('span.open_gis_editor').die('click');
$("input[name='gis_data[save]']").die('click');
$('input.checkbox_null').die('click');
@ -245,6 +247,7 @@ AJAX.registerTeardown('tbl_change.js', function () {
$("select[name*='funcs']").die('click');
});
/**
* Ajax handlers for Change Table page
*
@ -255,6 +258,24 @@ AJAX.registerTeardown('tbl_change.js', function () {
AJAX.registerOnload('tbl_change.js', function () {
$.datepicker.initialized = false;
var $unsavedForm = false;
$(document).on('click', 'a', function(e){
if ($unsavedForm) {
var is_confirmed = confirm(PMA_messages.strConfirmNavigation);
if (! is_confirmed) {
e.preventDefault();
} else {
unsavedForm = false;
}
}
});
$("form#insertForm :input:not([type=hidden])").change(function(){
$unsavedForm = true;
});
$('span.open_gis_editor').live('click', function (event) {
event.preventDefault();
@ -303,7 +324,6 @@ AJAX.registerOnload('tbl_change.js', function () {
);
});
/**
* Reset the auto_increment column to 0 when selecting any of the
* insert options in submit_type-dropdown. Only perform the reset