Javascript 使用jQuery Mobile准备好文档后,将选择更改为非本机菜单
我在使用jQuery Mobile编写的web应用程序中有一个select,我想在页面呈现后向其添加Javascript 使用jQuery Mobile准备好文档后,将选择更改为非本机菜单,javascript,jquery-mobile,Javascript,Jquery Mobile,我在使用jQuery Mobile编写的web应用程序中有一个select,我想在页面呈现后向其添加data native menu=“false 我举了以下例子: HTML <div id="cont"> <select id="sel"> <option>test1</option> <option>test2</option> </select> </
data native menu=“false
我举了以下例子:
HTML
<div id="cont">
<select id="sel">
<option>test1</option>
<option>test2</option>
</select>
</div>
以上是我的看法
该属性添加得很好,但在尝试了我所能想到的一切后,使用.selectmenu()
,.trigger('create')
,.selectmenu(“刷新”,true)
等。选择没有从使用本机菜单更改为使用jQuery Mobile
显然,我缺少了一些东西,但它是什么?您需要在创建页面之前设置它
pagebeforecreate
事件
$(document).on("pagebeforecreate", function () {
$("#sel").attr("data-native-menu", "false");
});
在jQuery Mobile中,使用jQM而不是使用.ready()
,因为不建议这样做
$(document).on("pagebeforecreate", function () {
$("#sel").attr("data-native-menu", "false");
});