Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
After adding pushState, back button gives unexpected results, loads content partially

I have a multi-step form with "next" and "previous" buttons that dynamically change the content. I want to use pushState so that the customer can also click the "previous" and "forward" buttons on his browser and mimic the same behavior.

This is where I got so far: when the user presses the browser back button, the page does go back as expected, but it's missing content, and also the previous form fields are unfilled or dysfunctional. It's very hard for me to understand what exactly is going on...

Here is my code:

$(document).on('click', '.next-button', function () {
  window.history.pushState($(".one-shot-form").html(), '', "");
});

$(window).on("popstate", e => {
    $(".one-shot-form").html(e.originalEvent.state);
});

Note: ".one-shot-form" is the name of the form's container, for which I want to dynamically change the content.

Any help would be dearly appreciated!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda