禁用 TextField 上的 ExtJS Click 事件

ExtJS Click event on disabled TextField

我正在使用 ExtJS 3.4.0

我有一个包含 2 个单选框和文本框、一个“确认”按钮和一个“取消”按钮的表单。像这样 :

我的 TextFields 有一些验证限制,因此我的“确认”按钮被禁用,直到我的 TextFields 有效。

我最初的问题是,即使我的“未选中”文本字段之一无效,我也希望启用“确认”按钮。

我找到了一个解决方法:如果没有选中相应的单选按钮,则禁用 TextField。

但我也希望当我点击我的 TextField 时,相应的 Radio 被检查(就像我点击 Radio 本身或其标签),但我的点击监听器不工作,因为我的 TextField 被禁用。

请问有解决我的问题的方法吗?或者也许是我最初的问题?

谢谢!

这是我的部分代码:

this.paypalAccount = new Ext.form.TextField({
    name : 'paypalAccount',
    emptyText : 'Enter your Paypal account here',
    maxLength : 128,
    allowBlank : false,
    disabled : true,
    handleMouseEvents: true,
    listeners: {
        render: function() {
            this.getEl().on('click', function() {
                Ext.getCmp('paypalRadio').setValue(true);
            });
        }
    }
});

this.paypalRadio = new Ext.form.Radio({
    id : 'paypalRadio',
    boxLabel : 'Paypal',
    checked : false,
    inputValue : 'paypalAccount'
});

this.paypalRadio.on('check', function() {
    if(this.paypalRadio.checked) this.paypalAccount.enable();
    else this.paypalAccount.disable();
}, this);

您可以使用包装器组件并将点击事件附加到它。类似于:

{
    xtype: 'container',
    items: [{
        // YOUR TEXT FIELD
        xtype: 'textfield',
        id: 'paypalTextField',
        name: 'paypalAccount',
        emptyText: 'Enter your Paypal account here',
        maxLength: 128,
        allowBlank: false,
        disabled: true
    }],
    // Listeners of the wrapper Ext.Component
    listeners: {
        render: function (cmp) {
            cmp.getEl().on('click', function () {
                Ext.getCmp('paypalRadio').setValue(true);
            });
        }
    }
}