2012-07-12 2 views
0

나는 컨트롤러를 설정하여 Ext.XTemplate 이벤트에 응답하고 해킹 된 자바 스크립트를 많이 작성하는 일을 피하려고합니다.이벤트를 XTemplate - Sencha Touch 2에 등록 하시겠습니까?

불행히도 1) 클릭 이벤트를 기록하거나 2) componentQuery을 사용하여 XTemplate을 등록 할 수있는 방법을 찾을 수 없습니다.

다음은 기본 컨트롤러 설정입니다 :

config: { 
     refs: {   
      reportChooser: 'xtemplate[id=jobReportChooser]' 
     }, 
     control: { 
      reportChooser: { 
       tap: 'onAnonymousTap' 
      } 
     } 
    }, 

컨트롤러에서 할 수있는 방법이 있나요 또는 적어도 청취자를 정리?

답변

0

XTemplate에는 이벤트가 내장되어 있지 않으므로 직접적인 참조를 찾을 수 없지만 약간 좋은 방법이 있습니다. 보기에

를 사용하여 응용 프로그램 dispatch method을 의미하는 방법을

initialize: function() { 
    this.element.on({ 
     tap: function(e, dom) { 

      var el = Ext.get(e.target), 
       elParent = Ext.get(e.parent), 
       fireEvent; 

      window.jobAction = this; 
      window.jobEl = el; 

      if (el.hasCls('job-start') || el.parent().hasCls('job-start')) { 
       fireEvent = 'start'; 
      } else if (el.hasCls('job-hold') || el.parent().hasCls('job-hold')) { 
       fireEvent = 'hold';      
      } else if (el.hasCls('job-report') || el.parent().hasCls('job-report')) { 
       Ext.Viewport.setMasked({ xtype: 'loadmask' }); 
       var teamId = APPNAME.currentItem.data.teamId; 
       var jobId = APPNAME.currentItem.data.jobId; 

       APPNAME.app.dispatch({controller: 'Jobs', action: 'displayReportChooser', args:[teamId,'job',jobId]}) 
      } 

      if (fireEvent) { 
       Ext.Viewport.setMasked({ xtype: 'loadmask' }); 
       this.fireEvent(fireEvent, Alloy.currentJob, el); 
      } 

     }, 
     delegate: '.job-info', 
     scope: this 
    }); 
} 

초기화합니다. 그것은 훨씬 쉬워 질 것이며 컨트롤러 내부에서 작업을 구성하는 데 도움이 될 것입니다.

http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Application-method-dispatch