【发布时间】:2014-06-02 00:35:38
【问题描述】:
我已经研究过这个问题,但这并不能解决我的问题 How to use up() in Ext.Button handler
我正在尝试实现一个简单的按钮处理程序,并且想要处理面板工具栏的按钮。我在面板中定义了一个 onNewFeed3 函数,不确定在单击按钮的点击事件时如何调用它。我不想使用单独的控制器类,但希望它全部在 View 类中。上面的链接似乎回答了这个问题,我仍然收到我在下面代码中提到的两个错误。
第一个注释之后的第一个代码的原因是为了确定“this”的 XType,我不确定最好的方法是什么,因为我得到了一个 TypeError
谢谢
Ext.define('Volt.view.FeedView', {
extend: 'Ext.Panel',
requires: [
'Ext.TitleBar',
'Ext.Button',
'Ext.Toolbar'
//'Ext.Panel'
],
xtype: 'feedViewCard',
config: {
iconCls: 'action',
title: 'FeedView',
layout: {
type: 'vbox'
},
items: [
{
xtype: 'toolbar',
title: 'Home',
docked: 'top',
items: [
{
xtype: 'spacer'
},
{
xtype: 'button',
text: 'New2 Feed',
ui: 'action',
id: 'new_note_button',
/* I HAVE TRIED THIS AND DOES NOT WORK - GIVES TypeError : undefined is not a function */
handler: function(){
console.log('button tapped inline handler, xtype =');
console.log(this.getXTypes());
},
/* and this gives the same error as well : TypeError : undefined is not a function*/
handler: this.up('feedViewCard').onNewFeed3,
scope: this
}
]
}
]
},
onNewFeed3: function(){
console.log('New Feed 3 button clicked');
}
});
【问题讨论】:
标签: javascript extjs sencha-touch