我有一个脚本把手..
<script id="ownerItem" data-template-name='ownerItem' type="text/x-handlebars">
{{value.UserName}} <button {{action "remove" on="click"}}>Remove</button>
</script>
它的观点..
ResAdmin.ownerView = Ember.View.extend({
templateName: 'ownerItem',
remove: function() {
var selectedRest;
selectedRest = ResAdmin.adminController.get('selectedRestaurant');
alert(value.RestaurantOwnerID);
return $.ajax({
url: '/api/RestaurantOwner/' + value.RestaurantOwnerID,
cache: false,
type: 'delete',
data: {
RestaurantID: selectedRest.RestaurantID,
MethodOverride: 'delete'
},
dataType: 'jsonp',
success: function(data) {
return ResAdmin.adminController.getRestaurantList();
}
});
}
});
在其他一些视图中,我正在使用此视图,如
{{#each ResAdmin.adminController.selectedRestaurant.Owners}}
{{view ResAdmin.ownerView valueBinding="this" content="this"}}
{{/each}}
但是当我点击我的嵌套视图的删除按钮时,我收到错误(值未定义)...有人可以帮助我吗?
答案 0 :(得分:1)
value是ownerView的属性,因此您需要使用this.get('value')
对其进行限定e.g。
this.get('value').RestaurantOwnerId