Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
beforeunload está navegando a la página visitada anteriormente en lugar de la URL de acción POST en el envío del formulario en Javascript
  1. Tengo una página en la que quiero configurar las fechas seleccionando las fechas con el selector de fechas y agregarlas a la tabla dinámica usando javascript en la misma página.
  2. Tengo varias fechas en la tabla pero no las guardé o aún no hice clic en el botón Enviar, pero hice clic en la pestaña secundaria en la misma página para navegar a otra página y se abrió una ventana emergente que dice que tiene cambios no guardados
  3. Se hizo clic en permanecer en la misma página y las fechas agregadas están presentes en la tabla y se hizo clic en el botón Enviar.

¿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; } } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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() {}; } } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!