先看主要代码,如下:Ext.onReady(function(){   
Ext.create(Ext.window.Window,{
      width: 300,
      height: 220,
      items: Ext.create(Ext.form.Panel,{
items : [{
items : [new Ext.form.field.Checkbox({
boxLabel : '项目一',
name : 'aa',
inputValue : '0',
checked : true,
listeners : {
'check' : function()//check改为click也无效 {
alert("单击或选中有效吗?");
}
}
})]
}, {
items : [new Ext.form.field.Checkbox({
boxLabel : '项目二',
name : 'bb',
inputValue : '1',
checked : false,
listeners : {
'checkChange' : function()
{
alert("单击或选中有效吗?");
}
}
})]
}]
})
}).show();
    });    代表中已说明很清楚的了,我再简单的说明下,我就是想做到,选中复选框时,能触事件,上面的代码应该写得没什么问题吧,但我用了check,click,checkChange这几个事件,都没办法执行函数中去,很是奇怪,这到底是怎么回事呢?希望有高人解答下,多谢。

解决方案 »

  1.   

    你这样能跑起来?奇怪了,
    'check' : function()//check改为click也无效                    {
                            alert("单击或选中有效吗?");
                        }
    你把括号都注释掉了“{”
      

  2.   


    items: Ext.create('Ext.form.Panel',{ 要加上引号 另外:4.0中 用change事件代替了原来的check事件
      

  3.   

    另外我把你的代码给你简化了一下 原代码LZ套的层太多了~~Ext.onReady(function() {
    Ext.create(Ext.window.Window, {
    width : 300,
    height : 220,
    items : Ext.create('Ext.form.Panel', {
    bodyPadding : 10,
    width : 300,
    items : [{
    xtype : 'fieldcontainer',
    defaultType : 'checkboxfield',
    frame : true,
    items : [{
    boxLabel : '项目一',
    name : 'aa',
    inputValue : '0',
    checked : true,
    id : 'checkbox1',
    listeners : {
    'change' : function(item, check) {
                                                        //4.0中用change事件代替了check事件 但参数是一样的
    alert(item.id)
    }
    }
    }, {
    boxLabel : '项目二',
    name : 'bb',
    inputValue : '1',
    checked : false,
    id : 'checkbox2'
    }]
    }]
    })
    }).show();
    });
      

  4.   

    此为正解,非常感身,我有看了API,没认真看,太多了,也没一个个去试,还以为,是checkChange