Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Issue keeping preserved state #53

Closed
markace1246 opened this issue Aug 20, 2014 · 1 comment
Closed

Issue keeping preserved state #53

markace1246 opened this issue Aug 20, 2014 · 1 comment

Comments

@markace1246
Copy link

I can't seem to get the plugin working with my sample. I have a welcome page that navigates to a home page with a list of items. The home page is the state where I want to preserve the DOM. When I navigate back to the home page, the list is still in its previous position but the accordion is still not expanded like before.

Here's a codePen of the sample app http://codepen.io/markace1246/pen/BpzIv

Also, I noticed that the controller reloaded(I do not want the page to reload when navigating back to the home page).

Could you help me figure out where my issue lies?

@christopherthielen
Copy link
Owner

Have a look at the docs for Sticky State:

DOM and $scope of a Sticky State (and all activated substates) is retained until the parent state of the sticky state is exited.

In your pen, the important states are home.list and detail where home.list is sticky. When you transition from home.list to detail, it is exiting both home.list AND home. Since home (the parent state of the sticky state) gets exited, home.list is not retained.

I'm not sure if sticky states and DSR can be used on an abstract state. I suggest restructuring your state tree so the parent to the sticky state doesn't get exited when transitioning to the detail state.

Why not put detail below the list state: home.list.detail ? I suspect you don't need sticky states at all, although I don't know much about how ionic works. Alternatively, try marking home as sticky, or create a non-abstract DSR/sticky state as a parent to home.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants