在textarea上获取undefined

时间:2015-03-18 12:05:24

标签: extjs

我在textareafield上得到了未定义的内容..我的id为:msgArea,但是extjs在运行时将id更改为:msgArea-inputEl。我已经尝试过使用这两个ID,但两者都未定义。

    isoNS.PanelQDisableInfoMsg = Ext.create("Ext.window.Window", {
    title: 'Improtant information', 
    width: $(document).width() / 2,
    height: $(document).height() / 3,
    modal: true,
    resizable: false,
    style: 'position: absolute; top: 100px;',
    id: 'infoWindow',
    layout: {
        align: 'stretch',
        type: 'vbox'
    },
    dockedItems: [
        {
            xtype: 'textareafield',
            fieldStyle: 'background-color: #DFE9F6; background-image: none;',
            readOnly: true,
            height: ($(document).height() / 3) - 80,
            inputId: 'msgArea',
        },
        {
            xtype: 'button',
            text: 'Ok',
            id: 'OkButton',
            docked: 'bottom',
            handler: function() {
                var win = Ext.getCmp("infoWindow");
                win.close();
            }
        },
        {
            xtype: 'button',
            text: 'Test',
            handler: function() {
                var textArea = Ext.getCmp("msgArea");
                textArea.setValue("Text changed");
            }
        }
    ]   
}).show();

给出undefined的代码是这部分:

{
    xtype: 'button',
    text: 'Test',
    handler: function() {
        var textArea = Ext.getCmp("msgArea-inputEl");
        textArea.setValue("Text changed");
    }
}

我做错了什么?

另外。如何使extjs不要将运行时的id从msgArea更改为:msgArea-inputEl

1 个答案:

答案 0 :(得分:1)

我不知道Extjs的确切版本。 http://docs.sencha.com/extjs/4.0.7/上的api说:

inputId : String
  

将生成的输入DOM元素的id。默认   自动生成的ID。如果您手动配置,您   必须确保它在文档中是唯一的。

     

自2004年以来可用

如果您使用较旧版本的Extjs,则api会提供对象属性id:。根据这些描述,如果您使用此框架,框架将不会为此元素分配自动生成的对象ID。