[英]JQuery Mobile: How to re-render select box?
第一次,當我加載頁面時,我的選擇框為空:
<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);
不要問我為什么,但這只對我有用,直到我使用雙引號 - >“< - 對於本指令中涉及的所有字符串:
$(“#secondaryTitle”)。selectmenu(“refresh”,true); //工作
我這樣做了:
$('#secondaryTitle')。selectmenu('refresh',true); //不工作
它不起作用:S:S:S
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.