Search code examples
meteormeteor-blaze

Meteor form component rendering


Whats "best practice" for rendering components in a form based on user input? I want a second input field added to the form when a user clicks option 2 on the dropdown button. I also want this if show cleared when a user clicks another option.

<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
}
)};

Thank you.


Solution

  • You can show your elements on conditional basis with helpers.On your second button click you can set a session and use it in a helper.Then in your html page use {{#if}} your element {{/if}}

    And for clearing it , destroy this session.

    Hope this make sense to you.If any query lmk