我正在嘗試向我的按鈕添加一個偵聽器,以便當它被點擊時,它會將'textId'文本字段中的內容加載到上述文本字段上方的html文本中,按鈕。這樣,他們可以在該字段中輸入多個內容,並在以後不需要時刪除它們,因爲文本是通過刪除按鈕加載的。Uncaught TypeError:Object#<Object> has no method'getValue'
createTextAndButton: function(fieldId, v, textId, field, text, num) {
var n = new Number(num);
var ct = new Ext.container.Container({
xtype:"container",
layout:"vbox",
//padding:"5 0",
items: [{
xtype:"container",
itemId: fieldId,
}, {
xtype: "container",
layout:"hbox",
padding: "5 0",
items: [{
xtype: 'textfield',
vtype: v,
name: textId,
fieldLabel: field,
validateOnBlur: true
}, {
xtype: "button",
text: text,
width: 115,
handler: function() {
ct.down('#' + fieldId).add(Ext.ComponentMgr.create({
xtype: "container",
itemId: 'entry' + n,
layout: "hbox",
padding: "5 0",
items: [{
xtype: "component",
html: "<p>" + textId.getValue() + "</p>"
}, {
xtype: "button",
itemId: 'dButton',
text: "delete",
width: 80
}
}]
}));
n++;
}
}]
}]
});
return ct;
}
我越來越遺漏的類型錯誤:對象ignoreField沒有法「的getValue」當我點擊的按鈕。我不確定爲什麼textfields的getValue方法不起作用,或者我正在做一些明顯錯誤的事情。
如果你路過它是文本框的id'textId'你可能想嘗試 'HTML:Ext.Container.getComponent( '文本ID')的getValue()' – cclerville
getComponent不是。一個靜態方法。 –
@EvanTrimboli哦,我明白了。我也注意到我的評論中有一個錯誤。我打算放的是'Ext.container.Container.getComponent'。我也正在閱讀文檔,並閱讀最好使用itemIds上面的方法,這導致了我的建議。但是你是正確的,即使那樣它不是正確的方式來使用它.http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Component-cfg-itemId – cclerville