javascript – JQuery Mobile:如何重新渲染选择框?

第一次,当我加载页面时,我的选择框为空:
<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.

解决方法

没关系!

我应该正确检查文件

//refresh value         
$('#select').selectmenu('refresh');

//refresh and force rebuild
$('#secondaryTitle').selectmenu('refresh',true);

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...