[英]Sencha Touch 2: Change the text of an HTML button in itemTpl
在我的DataView的itemTpl中,有以下幾行:
<div class="btn" id="colorbtn" uniqueId="{id}">{[this.getColorButton(values)]}</div>
在我的聽眾中,我有以下內容:
listeners : {
element : 'element',
delegate : '#colorbtn',
tap : function(item, idx, el, evt) {
// gets the item you tapped
btnId = el.getAttribute('uniqueId');
//Ext.getCmp('colorbtn').setText('New Value');
alert("hello "+btnId );
}
}
如您所見,我試圖使用Ext.getCmp
獲取按鈕並設置新文本,但這Uncaught TypeError: Cannot read property 'setText' of undefined
了錯誤Uncaught TypeError: Cannot read property 'setText' of undefined
。 有沒有辦法實現我的追求?
用Ext.get()包裝事件中返回的element變量,這將檢索Ext.dom.Element對象。 然后,您可以使用Ext.dom.Element的可用方法。
例:
Ext.get(el).setHtml('New Value') ;
注意:自動修復是否通過AJAX或DOM重新創建了具有相同ID的對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.