메뉴 체크 항목 이벤트를 처리하는 올바른 방법은 무엇입니까? 그런 다음 기능Extjs 4.1 변경 리스너 확인
{
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!');
}
}
감사합니다. Wilk .. – Noon
환영합니다;) – Wilk