OOOOOOOOOOK after hours of fail i finally got what I needed, understanding ember deprecations was helpful ha. However, I am not sure if this is the best/proper way to handle. Can someone please let me know if there is a better alternative.
The functionality for this is: On click save data from input then add another input, while still showing prior data.
I have a model that holds a temp value and an array.
App.ApplicationRoute = Ember.Route.extend({
model:function(){
return {singleVal:'',images:[]}
}
})
I have a template that displays a blank input which the value is always pointing to the model temp value. It also loops the model.images and displays any data if there. Since its written with an #each it is updated whenever the model changes :)
{{#each model.images as |info|}}
<label>image:</label>
{{input value=info}}<br/>
{{/each}}
image {{input value=model.singleVal}}<br/><br/>
<button {{action "addField"}}>ADD INPUT FIELD</button>
The controller listens for a click. Then just adds the temp value to the images array in the model. It then clears out the temp variable so it wont show on re render.
App.ApplicationController = Ember.Controller.extend({
actions:{
addField:function(){
console.log(this.model.singleVal);
this.model['images'].addObject(this.model.singleVal);
this.set('model.singleVal','')
}
}
})