![](/img/trans.png)
[英]How to refresh all select fields on changing to landscape mode with selectBoxIt?
[英]Selectboxit - How to refresh selected values in selectboxit
我正在使用selectboxit插件 - http://gregfranko.com/jquery.selectBoxIt.js/
使用普通的select元素,設置所選元素的prop將更新UI。 使用selectboxit它無法正常工作。
演示 - http://jsfiddle.net/uXM6Y/
var selectBox = $("select#test").selectBoxIt().data("selectBoxIt");
$('.btn').click(function(e){
$('#test option:contains("Great")').prop('selected', true);
});
當我單擊演示中的更新按鈕時,選擇未設置為更新的值。 如果我刪除selectboxit插件,它工作正常。
您想使用selectboxit方法API,該API在您的插件版本中不存在。
從這里獲取它(確保選擇了setOption方法供您下載): http : //gregfranko.com/jquery.selectBoxIt.js/customDownload.html#javascript-downloads
並按如下方式更改您的JavaScript:
var selectBox = $("select#test").selectBoxIt().data("selectBoxIt");
$('.btn').click(function(){
selectBox.selectOption('Great');
});
編輯:這是使用完整的selectboxit插件的小提琴的更新版本: http : //jsfiddle.net/uXM6Y/2/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.