Thanks for that link, using something I saw there I did some more digging and found this fiddle which helped me do this with ember…
Basically I now have this…
App.InputFormView = Ember.View.extend({
templateName: 'input-form',
ingrs: [{ingredient: ''}],
newIngredient: function(){
this.get('ingrs').pushObject({ingredient: ''});
},
submit: function(){
alert(this.get('ingrs'));
}
});
My problem now is how can I get the values from the inputs.
My template looks like this…
<script type="text/x-handlebars" data-template-name="input-form">
{{#each view.ingrs}}
{{input valueBinding="ingredient" classNames="ingredient-input"}}<br>
{{/each}}
<button id="ingredient-btn" {{action "newIngredient" target="view"}}>New Ingredient</button><br>
<button id="submit-btn" {{action "submit" target="view"}}>Find Me Something to Eat!</button>
I’ve tried to figure out how to grab those inputs as a list of ingredients so I can use them with an API later.
EDIT: Just noticed the “JSON.stringify” at the bottom of that fiddle which was commented out and using that I can alert the contents but I’m still not sure how to grab those values.