2014-02-10 141 views
1

我需要從MyControllerhandleUpdate方法觸發我的Summary控制器中的動作方法。從另一個控制器觸發控制器的「動作」

MyController

MyController = MyController.extend({ 

    needs: ['application', 'Summary'],  

    handleUpdate: function() { 
    var controller = this; 

    Ember.run.later(function() { 
     ... 
     ... 
    }.bind(this), 100); 
    }.observes('isUpdating') 
} 

Update控制器:

SummaryController.reopen({ 
    actions: { 
    update: function(source, callback) { 
    ... 
    ... 
    } 
    } 
}); 

由於

回答

2

抓住控制器實例然後使用方法send來觸發動作。

MyController = MyController.extend({ 

    needs: ['application', 'summary'],  

    handleUpdate: function() { 
    var controller = this, 
     summaryController = this.get('controllers.summary'); 

    summaryController.send('update'); 

    Ember.run.later(function() { 
     ... 
     ... 
    }.bind(this), 100); 
    }.observes('isUpdating') 
} 
+0

那麼,這回答了我的問題,但它並沒有解決我在我的應用程序中的問題。我會從名單上劃掉那個,然後把它放在別的地方。哈哈謝謝! – JDillon522

相關問題