¿Por qué en lugar de enviar el formulario, se redirige a la pestaña visitada anteriormente (pestaña secundaria mencionada en el paso 2)?
El siguiente código es para advertir, si hay datos no guardados:
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; } } });tal vez intente sobrescribir el evento con una función vacía:
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() {}; } } });