【问题标题】:How to Save Button on change如何保存更改按钮
【发布时间】:2017-11-02 12:37:57
【问题描述】:

为了在 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 均未触发。 我可以检测到复选框的变化吗?

【问题讨论】:

    标签: javascript user-interface extjs3


    【解决方案1】:

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

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

    【讨论】:

    • 在这两个命题中都是正确的:没有明确的数组表示法,更改侦听器不起作用!非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多