【发布时间】:2011-01-29 06:31:34
【问题描述】:
第一次,当我加载页面时,我的选择框是空的:
<select name="secondaryTitle" id="secondaryTitle"></select>
然后我进行 ajax 调用并获取上面选择框的 json 数据。
arrtitle = objSecTitle.getAllSecondaryTitle(serviceId); // its an ajax call, that returns json object
var obj = jQuery("#secondaryTitle");
removeAllOptions(obj);
for(i=0;i<arrtitle.length;i++)
{
obj.options.length=obj.options.length + 1;
obj.options[obj.options.length - 1].text = arrtitle[i][1];
obj.options[obj.options.length - 1].value = arrtitle[i][0];
}
function removeAllOptions(selectbox){
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
我的 ajax 调用非常完美。上面的代码还更改了下拉项。但是当我们使用 jQuery Mobile 时,UI 不会更新,因为它会显示/隐藏不同的 div 用于选择弹出窗口。
【问题讨论】:
标签: javascript html jquery-mobile