[英]data-native-menu=“true” doesn't work in multi select in jquery mobile
I want to have the native behavior when using mobile with the multiselect button. 我想在使用带multiselect按钮的移动设备时拥有本机行为。 Desktop can use the normal behavior ( data-native-menu="false"
). 桌面可以使用正常行为( data-native-menu="false"
)。
But when using the data-native-menu="true"
it just works when disabling jquery mobile with data-role="none"
. 但是,当使用data-native-menu="true"
它仅在通过data-role="none"
禁用jquery mobile时data-role="none"
。
I am using the chrome browser, also tested with android and windows phone, both with the same error. 我使用的是Chrome浏览器,也已在android和Windows Phone上进行了测试,但都存在相同的错误。
Please, find the fiddler: https://jsfiddle.net/titombo/uxamfLLf/ 请找到提琴手: https : //jsfiddle.net/titombo/uxamfLLf/
How to workaround this problem ? 如何解决此问题?
Possible Workaround : 可能的解决方法 :
data-role="content"
, I was getting error because it was inside a data-role="fieldcontain"
, so everything will be styled as jquery mobile and it will work with the native mobile selects. 用带有data-role="content"
的div环绕选择,由于出现错误,因为它位于data-role="fieldcontain"
,因此所有内容都将样式化为jquery mobile并将与本机移动选择一起使用。 Example: https://jsfiddle.net/titombo/v5DC3/331/ 示例: https : //jsfiddle.net/titombo/v5DC3/331/
Caution : In browser's it doesn't work. 注意 :在浏览器中不起作用。
For working with Desktop and Mobile I would add the attributes for data-native-menu="false"
by checking if is a Desktop browser with jQuery
and would not add anything if is a mobile. 对于桌面和移动设备,我将通过检查是否是带jQuery
的桌面浏览器来添加data-native-menu="false"
的属性,如果是移动设备则不添加任何内容。 Or in my case that I am using ASP.Net MVC I check with: 或者在我使用ASP.Net MVC的情况下,请检查:
for using the placeholder I made like this on the initial call: 我在初始调用中使用占位符的原因是这样的:
$('select span').first().text('Please, select element') $('select span')。first()。text('请选择元素')
if (!Request.Browser.IsMobileDevice) 如果(!Request.Browser.IsMobileDevice)
If you look at the jQM docs it clearly states: 如果您查看jQM文档,它会明确指出:
Currently jQuery Mobile only supports the multiple attribute on a select with nativeMenu set to false. 当前,jQuery Mobile仅在将nativeMenu设置为false的select上支持multiple属性。
http://api.jquerymobile.com/selectmenu/ http://api.jquerymobile.com/selectmenu/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.