How to bind a Knockout js model to a wizard style UI

后端 未结 1 1015
渐次进展
渐次进展 2021-02-14 12:27

I am using Knockout js. I have a view model that contains an array of objects and I want to allow the user to edit one of the objects using a wizard style interface. The

相关标签:
1条回答
  • 2021-02-14 12:57

    I think that a good way to do this is to have your view model be an array of steps and bind your UI to the "selectedStep". Then, each step can dynamically choose which template that it wants to use (like in this post).

    Here is a rough sample of the idea: http://jsfiddle.net/rniemeyer/SSY6n/

    This way the template bindings handles generating/binding/cleaning up the dynamic content based on whatever step is selected. If the steps are in an observableArray, then you could even dynamically add steps. Maybe you have a list of all of the possible steps and then have an "activeSteps" array that represents the steps that are currently valid based on the user's choices.

    0 讨论(0)
提交回复
热议问题