我需要将onchange或change事件添加到tpl内的select标记中,我有以下内容,但它不起作用。我试图使用Ext.DomHelper创建元素,但是找不到任何标签来进行追加。
这是我的代码!
tpl = new Ext.XTemplate(
'<tpl for=".">',
' <div class="container " style="margin-top:100px;">',
' <div class="row">',
' <tpl for="' + dataPhrases + '">',
' <div class="col-md-12 col-sm-6 col-xs-3">',
' <div> {[this.getPhraseWithCombobox(values.phrase, values.wordsToChange,xindex)]}</div>',
' </div>',
' </tpl>',
'</div>',
'</div>',
'</tpl>', {
getPhraseWithCombobox: function(phrase, words, i) {
var dh = Ext.DomHelper;
var f = phrase.split(/[ ]+/);
var selectList = document.createElement("select");
selectList.setAttribute("id", "mySelect" + i);
selectList.setAttribute("onchange", "myFunction()");
for (var j = 0; j < valuesCmbx.length; j++) {
var option = document.createElement("option");
option.setAttribute("value", valuesCmbx[j].id);
option.text = valuesCmbx[j].text;
selectList.appendChild(option);
}
for (var l = 0; l < words.length; l++) {
console.log(l);
f.splice(words[l].pos, 1, selectList.outerHTML);
str = f.join(" ");
}
return str;
}
}
);