我在尝试更新模型值时出现问题,PendingActionController.updateStage方法被调用我需要它来更新相关模型&反映更新的值。如果我在PendingController中创建另一个方法,如ShowMessage,它将显示警报。我应该如何从emberjs中的子控制器重新加载模型?
请解释我应该使用什么方法?
例如,以下是代码:
<script type="text/x-handlebars" id="pending/_actions">
<div class="content-actions">
<h2>Pending Actions</h2>
<ul>
{{#each pendingstages}}
<li>
{{#unless refreshingStage}}
{{render 'pendingAction' this}}
{{/unless}}
</li>
{{/each}}
</ul>
</div>
</script>
<script type="text/x-handlebars" id="pendingAction">
<div class="actionsBox">
<div class="actionsBar">
<div {{bindAttr class=":actionStatus completed:blue:green"}} {{action updateStage this}}> </div>
</div>
<div class="clear-both"></div>
</div>
</script>
PendingController:
App.PendingController = App.BaseObjectController.extend(App.ActionsControllerMixin, {
needs: ['application'],
postRender: function() {
//Some code here....
},
pendingstages: function(){
return App.PendingStage.find({Id: this.get('model.id')});
}.property('model.id', '[email protected]', 'refreshStage'),
ShowMessage: function(){
alert('Inside Sohw message.');
},
});
PendingActionController
App.PendingActionMixin = {
isEditing: false,
canDelete: true,
canEdit: true,
toggleIsEditing: function(){
this.toggleProperty('isEditing');
}
};
App.PendingActionController = App.BaseObjectController.extend(App.PendingActionMixin, {
needs: 'pending',
postRender: function(){
//some code here...
},
updateStage: function(stage){
var self = this;
this.get('controllers.pending').send('pendingstages');
},
});
EDIT(1): Followignt是灰烬&余烬数据的版本: 余烬-1.0.0-master.js 余烬 - 数据 - master.js:CURRENT_API_REVISION:12
你使用的是什么版本的Ember和Ember-Data。? – kushdilip
请参阅编辑(1): – user1400290