2011-11-28 44 views
3

我试图将我的Sencha应用程序从Sencha1移植到Sencha2。Sencha 2:面板上的听众不工作

看来,我的听众都没有工作。对于Sencha2文档似乎有不同的事件,以及较小的一些事件:

http://docs.sencha.com/touch/1-1/#!/api/Ext.Panel

http://docs.sencha.com/touch/2-0/#!/api/Ext.Panel

有没有一种新的方式来做到这一点? Sencha1的听众是否尚未在Sencha2中实现?

Ext.define('MyApp.view.Loading', { 
     extend: 'Ext.Panel', 
     googleAnalyticsName: 'Loading', 
     id: 'loadingView', 
     xtype: 'loading', 
     config: { 
      fullscreen: true, 
      layout: 'vbox', 
      scrollable: false, 
      items: [{ 
       html: '<div id="loading-view" style="background-repeat: none;"><div id="loading-page-spinner"></div>' 
      }], 
      listeners: { 
       activate: function() { 
        console.log('activate listener'); 
       }, 
       afterrender: function() { 
        console.log('afterrender listener')    
       } 
      }, 
     }, 
    }); 

回答

2

这似乎工作:

Ext.define('MyApp.view.Loading', { 
     extend: 'Ext.Panel', 
     googleAnalyticsName: 'Loading', 
     id: 'loadingView', 
     xtype: 'loading', 
     initialize: function() { 

      this.on('activate', function() { alert('activate'); }); 

      this.callParent(); 
     } 
    ...