我已经定义了一个 Ext.navigation.View
,我需要将一个事件处理程序附加到我的代码中指定的元素,如下所示:
title: 'Timetable XXX',
iconMask: true,
iconCls: 'XXX-icon-timetable'
知道怎么做吗?
Ext.define('XXX.view.NavigViewTimetable', {
extend: 'Ext.navigation.View',
alias: 'widget.navigviewtimetable',
requires: [
'XXX.view.TimetableContainer',
'XXX.view.DetailView',
'XXX.view.TimetableEdit',
'XXX.view.TimetableDayList'
],
config: {
navigationBar: {
items: [
{
xtype: 'button',
text: 'Add',
itemId: 'addButton',
ui: 'custom-btn-up-timetable',
align: 'right',
hidden: false
},
],
ui: 'custom-toolbar-top-1L'
},
items: [
{
xtype: 'timetablecontainer'
},
//Toolbar
{
xtype: "toolbar",
docked: "bottom",
ui: 'custom-toolbar-2L',
items: [
{
xtype: "button",
text: 'Today',
ui: 'custom-btn-dwn-timetable',
//handler: this.onTodayButtonTap,
//scope: this,
itemId: 'todayButton'
},
{
xtype: 'spacer'
},
{
xtype: "segmentedbutton",
items: [
{
text: 'Daily',
ui: 'custom-btn-dwn-timetable'
},
{
text: 'List',
ui: 'custom-btn-dwn-timetable',
//disabled: true,
pressed: true
}
],
itemId: 'segBtn',
align: 'right'
}
]
}
],
listeners: [
{
delegate: '#addButton',
event: 'tap',
fn: 'onAddButtonTap'
},
{
delegate: '#todayButton',
event: 'tap',
fn: 'onTodayButtonTap'
},
{
delegate: '#segBtn',
event: 'toggle',
fn: 'onSegBtnToggle'
}
],
// I NEED ADD LISTEN TO AN EVENT HERE
title: 'Timetable XXX',
iconMask: true,
iconCls: 'XXX-icon-timetable'
},
onAddButtonTap: function () {
console.log("addItemCommand [NavigViewTimetable]");
this.fireEvent("addItemCommand", this);
},
onTodayButtonTap: function(){
console.log('onTodayButtonTap [NavigViewTimetable]');
this.fireEvent('todayButtonTapCommand', this)
},
onSegBtnToggle: function (segBtn, btn, isPressed) {
//console.log("'" + btn.config.text +"' on segmented button pressed" );
if (btn.config.text == 'List'){
this.fireEvent('listToggleCommand', this);
}else if (btn.config.text == 'Daily'){
this.fireEvent('dailyToggleCommand', this);
}
}
});