I have 1 form that I've separated into multiple divs, each with their own Next button.
Upon clicking "Next" some javascript fires (see below) that hides the current div and unhides the next div (i.e. next step in the form). The URL is also updated with an # and the name of the step (e.g. example.com/booking
turns into example.com/booking#contact-info
)
$('#booking-details-complete').click(function(event) {
$("#booking-details").css("display", "none");
$("#contact-info").css("display", "block");
});
The Next button code that fires this JS is:
<%= link_to "Next", '#contact-info', :id => "booking-details-complete"%>
The final piece of the form has a Submit button instead of a Next button, which sends one big POST request to the various models.
My problem is back button behavior: going back doesn't update the page. The URL changes correctly, but the parts of the form (i.e. the divs) don't update their show/hide state.
I'm so close to finishing this project, but just can't figure out this last piece. Any help much appreciated.
pushState
isn't working