【问题标题】:ExtJs 3.4 display error textfield in xtype: 'textfield' (MODx)ExtJs 3.4 在 xtype 中显示错误文本字段:'textfield' (MODx)
【发布时间】:2021-07-01 17:03:00
【问题描述】:

我有一个面板,哪个按钮显示此窗口:

   MyClass.window.Test = function (config) {
    config = config || {};
    Ext.applyIf(config, {
        title: 'Test',
        width: '1000',
        autoHeight: true,
        fields: [
            {
                xtype: 'panel',
                items: [{
                        layout: 'form',
                        items: [
                            {
                                xtype: 'textfield',
                                name: 'testfield',
                                fieldLabel: 'Test Label Textfield',
                                id: 'testfield',
                                emptyText: 'text',
                                allowBlank: true,
                                anchor:'95%'
                            }
                        ]
                    },
                ]}
        ],
        url: MyClass.config.connector_url,
        action: 'mgr/myext/create',
    });
    MyClass.window.Test.superclass.constructor.call(this, config);
};
Ext.extend(MyClass.window.Test, MODx.Window);
Ext.reg('test-window', MyClass.window.Test, MODx.Window);

按钮本身是这样的

{
xtype: 'button',
text: 'TEST',
cls: 'primary-button',
                handler:   function () {
                    MODx.load({
                        xtype: 'test-window',
                        listeners: {
                            success: {
                                fn: function () {
                                    this.refresh();
                                }, scope: this 
                            }
                        }
                    }).show();
                }
}

问题。当我第一次单击该按钮时,表单会正确显示。当我第二次单击时,textfield 消失,fieldLabel 重复 4 次(1 click normall2 click and more - crash)。 如果我用任何其他 xtype 替换 textfield - 一切正常。如果删除 id 效果很好(!!!)。但我需要 Ext.getCmp 的 id。我不明白为什么第一次一切都很好,但是当我再次单击时,它无法正确显示。我在任何地方都找不到类似的问题,并且很沮丧。任何使用 fieldlabel、layuot 属性的操作都无济于事。问题可能出在哪里?在工作版本中,我有大约 40 个文本字段。

【问题讨论】:

    标签: extjs extjs3 modx


    【解决方案1】:

    默认情况下,窗口不会在关闭时销毁,因此您有两个具有相同 id 的元素再次创建窗口。

    this.ident = config.ident || 'mywindow' + Ext.id();
    

    在窗口开始后的代码

    config = config || {};
    

    以后使用

    id: 'textfield' + this.ident
    

    将有助于绕过该问题。

    【讨论】:

    • 好的,谢谢!帮助满满!它帮助了我。我们将不得不重写所有标识符:-(
    猜你喜欢
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多