我试图在单击按钮时动态添加表单面板。我收到这些错误消息,但不确定为什么会发生。仅供参考,第101行是doLayout()调用。这是错误消息:
ext-all.js:133 Uncaught TypeError: Cannot read property 'id' of null
at Ext.form.BasicForm.initEl (ext-all.js:133)
at sb.onRender (ext-all.js:134)
at sb.render (ext-all.js:58)
at sb.render (ext-all.js:64)
at Ext.layout.ContainerLayout.renderItem (ext-all.js:65)
at Ext.layout.ContainerLayout.renderAll (ext-all.js:65)
at Ext.layout.ContainerLayout.onLayout (ext-all.js:65)
at Ext.layout.ContainerLayout.layout (ext-all.js:65)
at sb.doLayout (ext-all.js:64)
at sb.handler (rcm.js:101)
这是我的代码:
var fieldCount = 0;
var poolPanel = new Ext.Panel({
id: 'poolPanel', width: '99%', frame: false
});
var addSearchField = new Ext.Button({
id: 'addSearchField', text: "Add Another Search Field", style: 'margin: 1px 0px 5px 5px ',
handler : function () {
var spotifyRecordCompanies = new Ext.form.FormPanel({
id: 'searchBar' + fieldCount,
items: []
});
fieldCount++;
Ext.getCmp("poolPanel").insert(fieldCount, spotifyRecordCompanies);
Ext.getCmp("poolPanel").doLayout();
}
});
谢谢!
答案 0 :(得分:0)
好的,我已经知道了。
视口配置不正确,我只需要实现它即可。
问题与第101行无关,这只是我收到错误的地方,这正是让我感到困惑的地方。