Ember.js - Creating a multistep wizard - How to?

前端 未结 3 2101
你的背包
你的背包 2021-02-08 07:09

I need to create a wizard with multiple steps. Each step will display a form with options, and depending on the user choices, the wizard should go to a certain step, as well as

3条回答
  •  天涯浪人
    2021-02-08 07:37

    Sounds like you are on the right track.

    Create a template for each wizard step.

    Yes, that is a good start.

    Keep track of the current step. Where? Controller? Route?

    Either controller or route would work. Route makes most sense if you want bookmarkable urls for each step and for back/forward to work and is probably the most straightforward solution. Will assume you've chosen route.

    Display these templates into outlets, which should be rendered dynamically according to the current step. This is where I get completely lost. How to do this? Should each step have a different route or not?

    Since each step will be a route, ember will take care of rendering appropriate template automagically.

    Keep track of user answers in the controller.

    Once the wizard is finished, load the form template, which will read user preferences stored in controller.

    Think of "finished" as just another step. Each step gets it's own controller which is used to record user responses. The last controller uses "needs" to access earlier controllers in order to customize behavior based on responses to the wizard.

提交回复
热议问题