我正在关注模型changedFavorite
中包含方法的旧教程:
App.Bookmark = DS.Model.extend({
title: DS.attr('string'),
url: DS.attr('string'),
favorite: DS.attr('boolean'),
changedFavorite: function(){
this.get("transaction").commit();
console.log("favorite changed");
}.observes("favorite")
});
我收到错误TypeError: Cannot call method 'commit' of null
当勾选模板中的复选框时,应该调用该方法:
{{view Ember.Checkbox checkedBinding="favorite"}}
是this.get("transaction").commit();
或view Ember.checkbox
的替换代码吗?
答案 0 :(得分:1)
现在你必须使用save()
:
App.Bookmark = DS.Model.extend({
title: DS.attr('string'),
url: DS.attr('string'),
favorite: DS.attr('boolean'),
changedFavorite: function(){
this.save();
console.log("favorite changed");
}.observes("favorite")
});