2014-03-05 3 views
0

코드를 한 번 작성하기 위해 뷰에서 현재 루트 컨트롤러로, 그런 다음 다른 컨트롤러로 작업을 보냈습니다.Ember가보기에서 데이터를 보내면 오류가 발생합니다.

this.get('controller.controllers.study/study').send('processPersonData', data); 

* * 중단 : 컨트롤러에 직접 구현 된 액션 핸들러는 actions 객체에 액션 핸들러에 찬성되지 않습니다 (조치 : processPersonData에) Ember.ControllerMixin.Ember.Mixin.create.deprecatedSend

에서

이 전송 작업을 구현하는 올바른 방법은 무엇입니까? FYI : 보내기 작업이 올바르게 작동합니다.

답변

1

이 메시지는 작업을 처리하는 방법과 같이, 객체상의 '행동'해시에서해야 함을 나타냅니다 :

App.SomeController = Ember.ObjectController.extend({ 
    someVariable: null, 

    actions: { 
     processPersonData: function(context) { 
      //implementation 
     }, 
     otherAction: function(context) { 
      //implementation 
     } 
    } 
}); 

그것은 액션 처리를위한 단지 새로운 의미입니다. 당신이 당신의보기에서 컨트롤러의 액션을 호출하려고하는 경우에는 다음과 같이

0

, 당신은 Em.ViewTargetActionSupport 믹스 인을 사용해야합니다

App.DashboardView = Em.View.extend(
    Ember.ViewTargetActionSupport, { // Mixin here 

    functionToTriggerAction: function() { 
     var data = this.get('data'); // Or wherever/whatever the data object is 

     this.triggerAction({ 
      action: 'processPersonData', 
      actionContext: data, 
      target: this.get('controller') // Or wherever the action is 
     }); 
    }, 
}); 

App.DashboardController = Em.ObjectController.extend(

    // The actions go in a hash, as buuda mentioned 
    actions: 
     processPersonData: function(data) { 
      // The logic you want to do on the data object goes here 
     }, 
    }, 
}); 
관련 문제