2015-03-25 72 views
1

我正在開發使用sencha touch的移動應用程序。問題是我點擊它後我的按鈕沒有切換到新的視圖。Sencha - 無法點按按鈕

我的代碼

視圖/ LoginUsername.js

Ext.define('RibMobile.view.LoginUsername', { 
    extend: 'Ext.form.Panel', 
    xtype: 'loginusernamepage', 
    requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label', 
     'Ext.Img' 
    ], 
    config: { 
     title: 'Login', 
     items: [{ 
      /* ? */ 
     }, { 
      xtype: 'button', 
      itemId: 'nextButton', 
      ui: 'action', 
      padding: '10px', 
      text: 'Next' 
     }, { 
      /* ? */ 
     }] 
    } 
}); 

控制器/ Login.js

Ext.define('RibMobile.controller.Login', { 
    extend: 'Ext.app.Controller', 
    config: { 
     refs: {}, 
     control: { 
      nextButton: { 
       // On the tap event, call onNewTap 
       tap: 'onPasswordTap' 
      } 
     } 
    }, 
    //called when the Application is launched, remove if not needed 
    launch: function(app) {}, 
    onPasswordTap: function() { 
     // When the user taps on the button, create a new reference of our New view, and set it as the active 
     // item of Ext.Viewport 
     Ext.Viewport.setActiveItem(Ext.create('RibMobile.view.LoginPassword')); 
    } 
}); 

app.js

Ext.application({ 
    name: 'RibMobile', 

    requires: [ 
     'Ext.MessageBox' 
    ], 

    controllers: [ 'Main', 'Login' ], 

    views: [ 
     'Contact', 
     'Locate', 
     'LoginUsername', 
     'LoginPassword', 
     'Main', 
     'Promotion' 
    ], 
    /* ? */ 

請指點如何觸發按鈕。謝謝。

回答

1

您錯過了按鈕與其控件之間的映射。

添加對它的引用,它應該工作:

refs: { 
    nextButton: 'button[itemId=nextButton]' 
}