Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: A canonical example of using Iron Router with wizard-style templates? #979

Open
aadamsx opened this issue Oct 30, 2014 · 6 comments

Comments

@aadamsx
Copy link

aadamsx commented Oct 30, 2014

I'd like to build a wizard, with next/previous and maybe a sidebar with the step you're currently on and status of each step.

I'm using Iron Router and Meteor 1.0.

I'm also using the Autoform repository (but that's not mandatory).

I'd also like to preserve inputs between routes. I could have a submit button on each step as well. The requirements are kinda up in the air.

Anyhow, I found this example from @cmather http://stackoverflow.com/questions/18732872/preserve-form-inputs-between-routes, is this the best way? Is there a place I can get a more flushed out example?

@cmather
Copy link
Contributor

cmather commented Oct 30, 2014

Hey @aadamsx, definitely need an example here. We also need to make some improvements around not creating new controller instances each time. I put it in the backlog for when I do the next batch of work on this. But for now, you can already accomplish this if the route doesn't change (e.g. use query parameters or hash values to stay on the same route but only invalidate the params). You can get the parameters reactively by calling this.getParams(). That way, an entirely new controller won't get created (so long as the route remains the same - the main url hasn't changed, only query params or hash frag). Then you can use a state value (this.state.get/set) or (Session.get/set) to decide which part of your template is visible.

@aadamsx
Copy link
Author

aadamsx commented Oct 30, 2014

Sounds good. But at this point I'm too new to Iron Router/Meteor to go at it alone. I'll need at least some code for reference/to go on (doesn't have to be 100%) before I feel comfortable forging ahead.

If you could provide a quick mock up, that could get me started.

Right now I'm trying to do it without IR params, just using the Submit of Autoform and either saving the data at each point, then linking to the next page, or saving the state in a Session and linking to the next page and saving at the end -- but I just started this and really haven't gotten too far yet.

@cmather
Copy link
Contributor

cmather commented Oct 30, 2014

Happy to do that. But it might be a few weeks. Alas, I'm taking a small vacation starting this afternoon! But I'll try to get something before we leave.

@aadamsx
Copy link
Author

aadamsx commented Oct 30, 2014

Greatly appriciated.

@dandv
Copy link
Contributor

dandv commented Nov 4, 2014

👍 for support for stateful/sticky routes, similar to Angular's ui-router-extras. For the best UX, form inputs, scroll state, text selection etc. should be preserved when navigating back to a route.

@ovidb
Copy link

ovidb commented Nov 5, 2014

+1

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

No branches or pull requests

4 participants