流星窗体组件渲染

Meteor form component rendering

什么是 "best practice" 以基于用户输入的形式呈现组件? 当用户单击下拉按钮上的选项 2 时,我希望将第二个输入字段添加到表单中。如果在用户单击另一个选项时清除显示,我也想要这个。

<form>
<button class='test'>my dropdown button with option 1,2,3</button>
<input type=text> input field 1</input>
<!-- if button clicked options 2, add second input field -->
<input type=text>input field 2</input>
</form>

Template.name.events({
 'click .test': function() {
// something to render input field 2
}
)};

谢谢。

您可以通过 helpers.On 有条件地显示您的元素,您可以点击第二个按钮设置会话并在 html 页面的 helper.Then 中使用它 使用 {{#如果}}你的元素{{/if}}

为了清除它,销毁这个会话。

希望这对 you.If 任何查询 lmk

有意义