views:

60

answers:

3

Scenario:

  • A page is loaded with a complex UI on it.
  • User does some actions which alter data via Ajax callbacks, changes are reflected on the UI by DOM manipulation (e.g. via jQuery).
  • User clicks a link to go to another page (say a details page).
  • User clicks the back button to go back to the original UI page.
  • User sees out-of-date information - it looks like the changes he made (in step 2) never happened.

How do you deal with this situation?

+1  A: 

Cookies. The only way to save information after the user leaves a page and comes back is with cookies.

Better way to do this is

0. user goes to your page 
1. A page is loaded with complex UI based on what is saved in the users cookies (default if no cookie)
2. user does some actions, which are saved into the cookie
3. user goes to another page
Not the only way. What if user has cookies turned off?
Metropolis
then they wont be able to save state between page views. if you have a better way of saving state on the www without cookies, let me know.
database or flatfile on server
Gutzofter
and then how are you going to tell your users apart?
@user350162 I think his point is that that cookies are not the only way to do it
Metropolis
no the point is there isnt another way to do it. his post didnt make any sense because it failed a major part of this problem, identifying your users. neither of you have shown me a way to save state on the web without cookies. just because you keep saying it doesnt make it true. so again, if you do have proof that it is possible to do this (in a widely applicable way); i would really like to see it. seriously.
ASP.NET supports cookieless sessions (http://msdn.microsoft.com/en-us/library/aa479314.aspx) , which can probably be implemented on other platforms.
UpTheCreek
yea that can easily be implemented on other platforms. its an interesting idea, even if it is sort of restrictive.
A: 

Hey UpTheCreek,

Whatever data is passed to the next page would need to also be passed back to change the UI to the way it needs to be.

This could be done with cookies, or it could be done using post data/server side logic. Just pass the values to the second page, and when the user wants to come back just be sure to pass them back as well and alter the interface depending on the values. You could even use a session for this is you wanted, but I think that may be overkill if this is the only place you will need it.

Metropolis

Metropolis
+1  A: 

You could force the page to refresh when the back button is pressed which will then pull the updated data from the server.

<META http-equiv="Cache-Control" content="no-cache">
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Expires" content="-1">

you might also want to take a look at Real Simple History and see if you can take advantage of their techniques to utilize the Back button.

Adam
+1 Good Idea Adam
Metropolis