I have a select form element with 3 options, and then a next button. When the next button is clicked it should look at the users selection and show a new form.
The current code is not giving me the desired results when the form element on change is fired.
I don't think using if blocks
is the proper way to achieve this.
Is there an alternate show/hide method I could use to handle a form elements on change?
here is a simple proof of concept in jquery, this one bypasses a submit btn.
hbr code
<div>
<label>Pick a form?</label>
{{view "select" content=myForms class="formSel"}}
</div>
<div>
<a {{action 'showForm'}}role="button">Next</a>
</div>
</form>
{{#if showForm1}}
<form>see form 1</form>
{{/if}}
{{#if showForm2}}
<form>see form 2</form>
{{/if}}
{{#if showForm3}}
<form>see form 3</form>
{{/if}}
ember code
myForms: ['1', '2', '3'],
showForm1: false,
showForm2: false,
showForm3: false,
actions: {
var formSel = $('.formSel');
showForm: function() {
var showForm1 = this.get('formSel.val()', []) == 1;
var showForm2 = this.get('formSel.val()', []) == 2;
var showForm3 = this.get('formSel.val()', []) == 3;
}
}