如何在更改时保存按钮

How to Save Button on change

为了在 extjs 中启用或禁用保存按钮,我做了一个简单的例子:

var panelData = [first = 'true', second = "false"]
TestFormPanel = new Ext.form.FormPanel({
    title: 'TestPanel',
    data: panelData,

    buttons: [
        new Ext.Button({
            id: 'saveButton',
            text: 'save',
            scope: this,
            disabled: true,
            handler: function () {
                panelData = this.getForm().getValues();
                console.log(panelData);
            }
        })],
    defaults: {
        xtype: 'checkbox',
        listeners: [{
            check: function () {
                console.log('check');
                this.saveButton.enable();
            }
        }]
    },
    items: [
        {
            name: 'first',
            fieldLabel: 'first box'

        },
        {
            name: 'second',
            fieldLabel: 'second box'
        }
    ]
});

Ext.onReady(function () {
    console.log('started');
    TestFormPanel.render(document.body)
})

永远不会触发 check 事件。我尝试了很多其他听众,例如 clickcontainerclickselect none 被触发。 我可以检测复选框的变化吗?

我认为问题在于该字段没有检查事件。 尝试使用更改事件。我还认为,数组表示法是明确的 http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.Checkbox-event-change 应该是:

listeners: {
        change: function () {
            console.log('change event');
        }
    }