在我的簡單的應用程序,我聽爲disclose
事件是這樣的:正確方法(或任何其他)在煎茶事件處理觸摸
在NotesList.js
(視圖)文件...
Ext.define("NotesApp.view.NotesList", {
extend : "Ext.dataview.List",
xtype : "noteslist",
...
config : {
onItemDisclosure : true, //adds the disclose arrow
}
});
NotesList用於NotesListContainer這是一個Ext.Container
。
然後在NotesListContainer.js
(圖)...
var notesList = {
xtype : "noteslist",
...
listeneres : {
disclose : { fn : this.onNotesListDisclose, scope : this }
}
};
this.add([topToolbar, notesList]);
功能做到這一點:
onNotesListDisclose : function(list, record, target, index, evt, options) {
console.log(' onNotesListDisclose() called'); //nevers gets logged
this.fireEvent('editNoteCommand', this, record);
}
然後在Notes.js
(控制器):
refs : {
//get elemets using xtype attr
notesListContainer : "noteslistcontainer",
noteEditor : "noteeditor"
},
//handlers for events
control : {
//define which events should this controller respond to
notesListContainer : {
//events fired by NotesListContainer
newNoteCommand : "onNewNoteCommand",
editNoteCommand : "onEditNoteCommand"
}
}
},
//Event/Command handler
onEditNoteCommand : function(list, record) {
console.log(' onEditNoteCommand called ');
this.activateNoteEditor(record);
}
我覺得問題在NotesListContainer.js中,我正在實例化列表。 如果我聽聽這樣的控制器事件:
refs : {
//get elemets using xtype attr
notesListContainer : "noteslistcontainer",
notesList : "noteslistcontainer list",
},
//handlers for events
control : {
//define which events should this controller respond to
notesListContainer : {
//events fired by NotesListContainer
newNoteCommand : "onNewNoteCommand",
//editNoteCommand : "onEditNoteCommand"
},
notesList : {
disclose : "onEditNoteCommand" //adding it this way works...
}
}
它工作得很好。但是,我寧願使用更多的應用程序特定事件,而不是非常通用的disclose
事件。 我是新來的sencha touch,任何幫助表示讚賞。
例如'onEditNoteCommand'比'披露'更有意義 –