Why instead of submitting the form, it redirects to previously visited tab(sub tab mentioned in step 2)?
Below code is to warn, if there is unsaved data:
var submitted = false;
$(document).ready(function() {
$('#addDates').click( function() {
submitted=true;
});
window.onbeforeunload = function () {
if (!submitted) {
return 'Do you really want to leave the page?';
} else {
window.onbeforeunload = null;
}
}
});
maybe try to overwrite the event with an empty function:
var submitted = false;
$(document).ready(function() {
$('#addDates').click( function() {
submitted=true;
});
window.onbeforeunload = function () {
if (!submitted) {
return 'Do you really want to leave the page?';
} else{
window.onbeforeunload = function() {};
}
}
});