我有一个名为editor_template的kendo模板,并且在模板中有一个<select>
元素。<select>
是一个下拉列表,根据我们从用户那里获取的信息,可以有任意数量的任何种类的名称。因此,我试图找到一种将<option>
元素插入select中的方法,但是到目前为止还没有成功。
我尝试过这样的方法:
$($('#editor_template').html()).find('#dropdownId').html().replace('variable', optionList);
这将获取我的<select>
元素,并替换变量,但editor_template中没有反映任何更改。
我也试图去.innerHTML
,而不是html()
,没有运气。
简单地做:
$('#editor_template').html().replace('variable', optionList);
什么都没做。
我有<select>variable</select>
,所以变量上的替换应该做到这一点,但是它不能代替任何东西。
如何获得这个已经在kendo模板中明确声明的<select>
,然后将我动态获取的任意多个选项插入到下拉列表中?
发布于 2017-05-05 14:29:35
我看不出.replace()是jQuery函数,我不清楚什么“变量”选择器是.
假设dropdownID是<select>
标记的ID,optionList包含optionList,则尝试$('#editor_template').find('#dropdownId').html(optionList);
https://stackoverflow.com/questions/43814084
复制