如何“关闭” jQuery Mobile 的
我需要关闭 jQuery Mobile 的 下拉列表的外观。
目前我的标记是(出于显示目的减少选项数量):
<div data-role="fieldcontain">
<label for="state">State:</label>
<select name="state" id="state" data-role="none">
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN" selected="selected">Minnesota</option>
<option value="MS">Mississippi</option>
</select>
</div>
我尝试在
有没有办法“关闭”jQuery Mobile 仅选择下拉列表?
I need to turn off jQuery Mobile's styling of <select>
drop downs. Ultimately I'd like the device itself (iPhone, Android, Blackberry, etc.) to determine how the <select>
drop down looks.
Currently my markup is (option quantity reduced for display purposes):
<div data-role="fieldcontain">
<label for="state">State:</label>
<select name="state" id="state" data-role="none">
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN" selected="selected">Minnesota</option>
<option value="MS">Mississippi</option>
</select>
</div>
I tried using data-role="none"
on the <select>
but nothing changed.
Is there a way to "turn off" jQuery Mobile for just the select drop down?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
根据 http://jquerymobile.com/test/docs/forms/docs-forms.html
如果您希望 jQuery Mobile 不影响特定的表单控件,只需为该元素指定属性 data-role="none"。例如:
according to http://jquerymobile.com/test/docs/forms/docs-forms.html
If you'd prefer that a particular form control be left untouched by jQuery Mobile, simply give that element the attribute data-role="none". For example:
从版本 1.1 开始,正确的方法是:
data-enhance="false"
您还需要将此行添加到配置中:
http://jquerymobile.com/test/docs/forms/forms-all-native.html
Since Version 1.1 the right way to do it is:
data-enhance="false"
You will also need to add this line to config:
http://jquerymobile.com/test/docs/forms/forms-all-native.html
在 mobileinit 内,修复 jQM 选择器以按预期运行:
Inside mobileinit, fix the jQM selector to behave as expected:
虽然这个问题已经被认为已经得到解答,但我想添加更多行,因为答案对我来说并不是“开箱即用”的,这可能会为其他人节省一些时间。
就我而言,当智能手机应用程序运行到 Android 中时,我会禁用它的本机下拉菜单(因为打开本机下拉菜单时会出现一些丑陋的问题,已在另一个线程中报告)。为我解决问题的“魔咒”就是以下几行:
这些行位于在 jQuery 之后和 jQuery-Mobile 之前加载的自定义脚本中。 保持顺序很重要,否则控件已经初始化并且没有任何效果!
我希望这个建议可以为某人节省一些时间!
Although this question is considered answered already, I'd like to add some more lines, since the answer didn't work "out-of-the-box" for me, and this might save some time for others.
In my case, I'm disabling the native dropdowns for a smartphone application when it runs into Android (since it has some ugly issues when opening native dropdowns, reported already in another thread). The "magic spell" that solved the problem to me is just the following lines:
These lines are in a customization script loaded just after jQuery and just before jQuery-Mobile. It's important to keep the order, otherwise the controls are already initialized and it has no effect!
I hope this advice can save some time to someone!
是的,您必须进入控制 JQuery Mobile UI 下拉样式的 CSS 文件,并删除您不想显示的任何样式。
Yes, you have to go into the CSS file that controls the JQuery Mobile UI dropdown(s) style and remove any styling you don't want to appear.
他们仍在研究它,适用于最新的 git 代码,但我不推荐它:
https://github.com/jquery/jquery -mobile/issuesearch?state=close&q=select#issue/350
They're still working on it, works in latest git code but I wouldnt recommend it:
https://github.com/jquery/jquery-mobile/issuesearch?state=closed&q=select#issue/350
使用这个属性应该有帮助
Using this property should help
只需尝试来自 doc 的
data-native-menu="true"
:
通过将 data-native-menu="true" 属性添加到选择,框架将在单击选择按钮时使用浏览器的本机选择菜单。由于此选项不使用任何自定义菜单解析和菜单生成逻辑,因此它比自定义菜单版本要快得多。
自定义选择菜单添加了主题选择的功能,并提供跨平台的视觉一致性。此外,它还修复了某些平台上缺少的一些功能:Android 上的 optgroup 支持、WebOS 上的多选功能,并添加了一种优雅的方式来处理占位符价值观。
了解更多信息
just try
data-native-menu="true"
from doc :
By adding the data-native-menu="true" attribute to the select, the framework will use the browser's native select menu when the select button is clicked. Because this option doesn't use any of the custom menu parsing and menu generation logic, it is significantly faster than the custom menu version.
The custom select menus add the ability to theme the select and provide visual consistency across platforms In addition, it fixes over some missing functionality on certain platforms: optgroup support on Android, multi-select capability on WebOS, and adds an elegant way to handle placeholder values.
for more info