Meteor中多步注册流程的设计模式(Design pattern for a multiple step signup flow in Meteor)

编程入门 行业动态 更新时间:2024-10-19 00:27:02
Meteor中多步注册流程的设计模式(Design pattern for a multiple step signup flow in Meteor)

我正在尝试构建一个3步注册流程,即分布在3个屏幕/模板上,但使用相同的路径。 我正在使用Blaze和FlowRouter btw。

实现这一目标的简单模式是什么?

任何带领我走向正确方向的想法都值得赞赏,谢谢!

I'm trying to build a 3 step signup flow, i.e. spread out across 3 screens/templates, but using the same route. I'm using Blaze & FlowRouter btw.

What is a simple pattern to achieve this?

Any ideas to lead me in the right direction appreciated, thanks!

最满意答案

我已经使用动态模板和反应变量完成了这种模式。

一些示例代码可以帮助您入门

signup.html

<template name="signupContainer"> {{> Template.dynamic template=template}} </template> <template name="signupStepOne"> <h1>Step One</h1> <button id="next-step-btn">Next Step</button> </template> <template name="signupStepTwo"> <h1>Step Two</h1> </template>

signup.js

Template.signupContainer.onCreated(function () { var instance = this; instance.activeTemplate = new ReactiveVar('signupStepOne'); }); Template.signupContainer.events({ 'click #next-step-btn': function (event, instance) { instance.activeTemplate.set('signupStepTwo'); } }); Template.signupContainer.helpers({ template: function () { var instance = Template.instance(); return instance.activeTemplate.get(); } });

I've accomplished this pattern using dynamic templates and a reactive var.

Little example code to get you started

signup.html

<template name="signupContainer"> {{> Template.dynamic template=template}} </template> <template name="signupStepOne"> <h1>Step One</h1> <button id="next-step-btn">Next Step</button> </template> <template name="signupStepTwo"> <h1>Step Two</h1> </template>

signup.js

Template.signupContainer.onCreated(function () { var instance = this; instance.activeTemplate = new ReactiveVar('signupStepOne'); }); Template.signupContainer.events({ 'click #next-step-btn': function (event, instance) { instance.activeTemplate.set('signupStepTwo'); } }); Template.signupContainer.helpers({ template: function () { var instance = Template.instance(); return instance.activeTemplate.get(); } });

更多推荐

本文发布于:2023-07-26 00:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268380.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:流程   模式   Design   中多步   Meteor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!