Preserving State

Hi, I’m trying to create a prototype that allows the user to add products to a shopping cart (on page 1) and see the “Check Out” on a new page (page 2).

When I try to create a button on page 2 to go back and open page 1 the original page refreshes to the original state but I want the page to be in the same state as the user left it so the “selected” products can be seen,

What should I do? I just want to keep the state of a page the way the user left it so the user sees the same state when they go back to it.

Thank you!

Help.rp (80.6 KB)

1 Like

Hi CCL12,

I may be misunderstanding your question, but you could just add the same OnPageLoad interactions from Page 2 to Page 1 to get the repeater to stay in the same state it was left in. If you were opening Page 1 using the “Back to previous page (variable changes are not applied)” option or by using your browser’s back button, this would not work as variable changes are not saved. To work around this, you could use variables to keep track of the page you came from and then use that with conditional logic to open the corresponding “back” page.

If that wasn’t what you were looking for, could you provide some more specifics on what you’d like to see in your file? Feel free to look at my edited file and let me know where I misunderstood!

Help_EDIT.rp (84.7 KB)

Thanks! By the way, I’m having issues with preserving state between two states from two different Dynamic Panels witch are in different pages.
How can I do it?
Basically I want a back button that works between pages and states. For example, if I’m in page 2 on state 3 (Daniel) I want to go back to State 2(Contacts) in Page 1.

Thank you again!
Help2.rp (293.2 KB)

Hi CCL12,

If I’m understanding correctly, it sounds like you’d like to preserve states of dynamic panel in between pages. Did I get that right? If so, you would essentially do the same thing as the above where you create a global variable and save the state of the DP to this global variable, e.g. [[DPState]]. Using the OnPageLoad of the targeted page, add a “Set Panel State” interaction to set the panel state to the “Value” of the global variable:

Please note that the name of the states of the dynamic panel in the two pages must match exactly. If you had a dynamic panel on Page 1 with states: apples, oranges, and bananas, for example, then the dynamic panel on Page 2 must have the same state names of apples, oranges, and bananas (capitalization counts!).

Help2_EDIT.rp (409.0 KB)

1 Like

Hi again, thanks for your response but I still can’t preserve states without using buttons. Essencially, I’m trying to preserve states using swipes up and swipe down.
What am I doing wrong or what am I missing?
Help3.rp (293.0 KB)

Hi CCL12,

It looks like you already have the OnSwipeUp and OnSwipeDown actions on Page 1 changing the states, and have the actions set up to set the [[DPState]] variable to the value of the selected state. It looks like the animation timing on your state changes is interfering with setting the variable to the correct state (it’s setting it to the state from before the state change instead of the new state), so moving that variable action over to the OnPanelStateChange event should help to store the correct panel state value:

On Page 2, all you should need to do is set up an Open Link action on your back button to open a link to Page 1:

From there, the OnPageLoad event on Page 1 will set the dynamic panel to the value that you stored previously, so if the panel state was set to “Orders”, it will still be on “Orders” when the page loads:

If you want to also save the state of the dynamic panel that you have on Page 2, then you’ll want to create a second global variable and store that panel’s state in that new variable after you change states, and use OnPageLoad or OnLoad to set the panel state to the variable value (similar to Page 1). This way both panels will have their states preserved as you go back and forth between pages.

Hi All,

What would we need to do, if I don’t want to preserve a state.