2014-04-16 29 views
0

我通過這個sencha touch tutorial跟隨,但是,我無法獲取點擊事件觸發,我嘗試過使用id並且無法使用id來獲取參考..但沒有luck..here是我的代碼..sencha touch 2按鈕,在工具欄中點按事件不發射

查看:

Ext.define("NotesApp.view.NotesListContainer", { 
    extend: "Ext.Container", 
    xtype: "NotesListView", 
    config: { 
    items: [{ 
     xtype: "toolbar", 
     docked: "top", 
     title: "My Notes", 
     items:[{ 
      xtype: "spacer", 
      }, { 
      xtype: "button", 
      text: "New", 
      ui: "action", 
      action: "addNote", 
      id: "new-note-btn" 
      }] 
     }] 
     } 
    }); 

控制器:

Ext.define("NotesApp.controller.Notes", { 
     extend: "Ext.app.Controller", 
     config: { 
      refs: { 
       notesListView: 'NotesListView', 
       newNoteBtn: 'notesListView button[action=addNote]' 
      }, 
      control: { 
       tap: "onNewNote" 
      } 
     }, 
     onNewNote: function(){ 
      console.log("New button has been tapped!!"); 
     }, 
     launch: function() { 
      this.callParent(); 
      console.log("Launch in Notes.js"); 
     }, 
     init: function(){ 
      this.callParent(); 
      console.log("Init in Notes.js"); 
     } 
    }); 

我不能鍛鍊什麼我missing..when我點擊在工具欄中的新建按鈕上,沒有前夕nt似乎在控制檯日誌中沒有任何內容。我已經嘗試過Safari,Chrome和Firefox ..沒有快樂。請您快速查看一下,看看能否找到我錯過的東西?有沒有一種方法來調試Sencha Touch應用程序?

回答

0

嘗試使用:

newNoteBtn: 'button[action=addNote]' 

或:

newNoteBtn: '#new-note-btn' 

代替:

newNoteBtn: 'notesListView button[action=addNote]'