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

193
Views
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
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!