Extjs 4.1检查更改侦听器
处理菜单检查项事件的正确方法是什么 我有这个菜单:Extjs 4.1检查更改侦听器,extjs,extjs4.1,Extjs,Extjs4.1,处理菜单检查项事件的正确方法是什么 我有这个菜单: { xtype: 'button', id: 'types_btn', autoWidth: true, text: 'Types', menu: { xtype: 'menu', frame: true, id: 'types_menue', items: [
{
xtype: 'button',
id: 'types_btn',
autoWidth: true,
text: 'Types',
menu: {
xtype: 'menu',
frame: true,
id: 'types_menue',
items: [
{
xtype: 'menucheckitem',
id: 'f_type',
text: 'first',
listeners: {
checkchange: {
fn: me.onFirstButtoncheckchange,
scope: me
}
}
},
{
xtype: 'menucheckitem',
id: 's_type',
text: 'second',
listeners: {
checkchange: {
fn: me.onSecondButtoncheckchange,
scope: me
}
}
}
然后,功能:
onFirstButtoncheckchange: function(menucheckitem, checked, options) {
var t = Ext.getCmp('f_type');
if (t.checked)
goToFunction(???);
.
.
},
onSecondButtoncheckchange: function(menucheckitem, checked, options) {
var t = Ext.getCmp('s_type');
if (t.checked)
goToFunction(???);
.
.
},
1-是否仍然可以使用一个侦听器并在其中收集所有不同的函数
2-如何将当前项发送到goToFunction(),如代码中所示?只需为每个菜单检查项创建一个处理程序:
items: [{
xtype: 'menucheckitem',
text: 'select all' ,
id: 'first' ,
listeners: {
checkchange: me.myHandler
}
},{
xtype: 'menucheckitem',
text: 'select specific' ,
id: 'second' ,
listeners: {
checkchange: me.myHandler
}
}]
您的处理程序定义如下:
myHandler: function (menucheckitem, checked, opts) {
switch (menucheckitem.getId ()) {
// Here handles the first
case 'first':
if (checked) {
console.log ('First checked!');
goToFunction ();
}
break;
// Here handles the second
case 'second':
if (checked) {
console.log ('Second checked!');
goToFunction ();
}
break;
default:
console.log ('Whatever!');
}
}
看起来侦听器不太经常被触发。您可以改为使用checkHandler配置