2014-04-16 33 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]'