我似乎无法让我的 jQuery Mobile 样式应用于我动态填充的选择。我试过添加主题、手动添加样式、刷新、$('.ui-page-active').trigger('create');
等,但都没有成功。选择:
<select id="CandidatesListBox" data-placeholder="true" onchange="myMethod()" style="width: 100%" aria-haspopup="true" class="candidatesList" data-theme="c" ></select>
填充它:
var geocodeOption = document.createElement('option');
//fill option
if (_isMobile) {
$('#' + geocodesList.id).append(geocodeOption);
$('select#CandidatesListBox').selectmenu();
$('select#CandidatesListBox').selectmenu('refresh', true);
}
选择下拉列表本身具有正确的样式,但没有其他样式。如果我添加
geocodeOption.className = geocodeOption.className + 'ui-btn';
select 看起来就像一个选择和一个按钮,同样选项不包含任何样式。
我还尝试阅读 jQuery 表单 link 1和 link 2没有运气。我正在使用 jQuery Mobile 1.4.2。
最佳答案
这实际上不是问题。我无法设置选项的样式,因为一般来说,options cannot be styled .不过这不是问题,因为 Android 操作系统会处理选项样式。我看不到这一点,因为 Google Canary 没有呈现 Android 选项样式,而是呈现了 Windows 选项样式。
关于css - JQuery 手机 : Dynamically filled Selects do not get css styles,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24419389/