Question

I am developing a rails app. (I don't think this is a rails-specific problem) There's a reservation process which is consisted of 3 steps. When a user is on step 2 page, if the user clicks 'Previous' button, the form data in step 1 should be the same as before.

I attached "history.go(-1);" to the 'Previous' button.

It works on my firefox browser. But it doesn't work on some IE browsers. My IE works though.

How can I force it to preserve the form data when the page is back?

Thanks.

Sam

Was it helpful?

Solution

Can't rely on the client (javascript) for this kind of operation.

You save the data somewhere at step 1, so just restore it.

OTHER TIPS

look into having a hidden iframe on the page to store the data. I am not sure of the specifics of implementing this, but this is the technique people use to store the state of the page when the hash changes in the URL. Check if some libraries like dojo and jquery help support this situation.

You could save page 2's data to the database, or a server-memory cache, or a cookie or three, and restore it when the page is loaded.

ASP.NET does this automatically via ViewState (note: article is ancient, but still quite accurate). Perhaps you can adapt a similiar approach to Rails.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top