[英]JQuery Mobile data-native-menu=“false” throws an undefined error
Working on styling a menu with jquery mobile through a select list. 通过选择列表使用jquery mobile设计菜单样式。 The problem is, adding a data-native-menu="false" as an option throws an error when I append it to the header.
问题是,将data-native-menu =“ false”作为选项添加时,将其附加到标题时会引发错误。 The snippet of code that works is this:
起作用的代码段是这样的:
var menu = '<div class="ui-select"><select name="menu-items" class="menu-items" id="menu-items" tabindex="-1" data-native-menu="false" >';
menu += '<option value="a">A</option> <option value="b">A</option>';
menu += '</select></div>';
$("div[data-role='header']", this.el).html(menu).trigger('create');
That error that it generates is this: 它产生的错误是这样的:
Uncaught TypeError: Cannot read property 'jQuery18303288714927621186' of undefined
In the example below, I removed the data-native-menu and it will work But the UI does not look at intended: 在下面的示例中,我删除了data-native-menu,它可以工作,但UI并未达到预期的效果:
var menu = '<div class="ui-select"><select name="menu-items" class="menu-items" id="menu-items" tabindex="-1" >';
menu += '<option value="a">A</option> <option value="b">A</option>';
menu += '</select></div>';
$("div[data-role='header']", this.el).html(menu).trigger('create');
What could be causing this problem? 是什么导致此问题?
Try this: 尝试这个:
<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
<title>data-natice-menu</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile.structure-1.2.0.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>
$(document).ready(function(e) {
var menu = '<div class="ui-select"><select name="menu-items" class="menu-items" id="menu-items" tabindex="-1" data-native-menu="false" >';
menu += '<option value="a">A</option> <option value="b">A</option>';
menu += '</select></div>';
$("div[data-role='header']", this.el).html(menu).trigger('create');
});
</script>
</head>
<body>
<div data-role="page" data-theme="a" id="page">
<div data-role="header" data-position="fixed"></div>
</div>
</body>
</html>
EDIT : I changed the code. 编辑 :我更改了代码。 I tested it and it shows select correctly.
我测试了它,并显示正确选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.