Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jQuery Mobile准备好文档后,将选择更改为非本机菜单_Javascript_Jquery Mobile - Fatal编程技术网

Javascript 使用jQuery Mobile准备好文档后,将选择更改为非本机菜单

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> </

我在使用jQuery Mobile编写的web应用程序中有一个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");
});