mercredi 11 février 2015

Ember trying to update element gives this.get(...).save is not a function

I am trying to learn Ember, and i have gotten to read and write new elements to my backend server. I am somehow stuck when trying to update.


this is my controller



App.TeamController = Ember.ObjectController.extend({
editMode : false,
actions : {
enterEdit : function() {
this.set('editMode', true);
},
saveEdit : function() {
this.set('editMode', false);
this.get('model').save();
}
}});


And this is my handlebar code:



{{# each team in model itemController="team"}}
{{# if team.editMode}}
{{input type="text" id="newName" value=team.name class="form-control"}}
{{input type="text" id="newLevel" value=team.level class="form-control"}}
<button {{action "saveEdit"}}>Save</button>
{{else}}
<p>{{team.name}} : {{team.level}} <button {{action 'enterEdit'}}>edit</button></p>
{{/if}}
{{/each}}


this gives me the following error message in the console:


TypeError: this.get(...).save is not a function.


I can not figure out what is wrong. Any help is appreciated.





Aucun commentaire:

Enregistrer un commentaire