Jquery mobile mobileinit初始选择器不工作
使用jQM 1.4,我正在使用Jquery mobile mobileinit初始选择器不工作,jquery-mobile,select,select-menu,Jquery Mobile,Select,Select Menu,使用jQM 1.4,我正在使用[data role='toggleselect']开发一个自定义的select小部件,如下所示: <select data-role="toggleselect"> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> &l
[data role='toggleselect']
开发一个自定义的select
小部件,如下所示:
<select data-role="toggleselect">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
这是我的证明,这是行不通的。我的select
元素仍在增强中。是的,这是在加载jQuery之后但在jQM之前放置的
为了进一步实验,我将以下initSelector硬编码到mobile.selectmenu
小部件下的jQM-1.4.js文件中:
$( document ).on( "mobileinit", function() {
$.mobile.selectmenu.prototype.initSelector += ":not(:jqmData(role='toggleselect'))";
});
initSelector: "select:not(:jqmData(role='slider')):not(:jqmData(role='flipswitch')):not(:jqmData(role='toggleselect'))"
当这是硬编码时,myselect
不会增强,因此工作正常
下面是我的文件的副本/粘贴:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>mobile.toggleselect</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$( document ).on( "mobileinit", function() {
$.mobile.selectmenu.prototype.initSelector += ":not(:jqmData(role='toggleselect'))";
});
</script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h3>mobile.toggleselect</h3>
</div>
<div data-role="content">
<select data-role="toggleselect">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
</div>
</body>
</html>
mobile.toggleselect
$(文档).on(“mobileinit”,函数(){
$.mobile.selectmenu.prototype.initSelector+=“:not(:jqmData(role='toggleselect'))”;
});
mobile.toggleselect
一个
两个
三
同样,如果我下载了jquery.mobile-1.4.0.js
文件的本地副本,并为mobile.selectmenu
硬编码initSelector
,它会正常工作
所以。。。我错过了什么?或者这是一个bug?这看起来像是jQuery Mobile API 1.4文档中的一个错误 分配自定义初始化选择器的步骤
删除
.prototype
,它将像一样工作。prototype
与一起使用。options
@Omar:谢谢,这很有效。然后我的问题变成:当它说使用$.mobile.selectmenu.prototype.initSelector
时,是不是错了?还是我只是误解了我读到的内容?所有小部件上都有同样的错误@Omar:是的,我也注意到了。我使用其他小部件进行了测试,得到了相同的(缺少)结果。我已经向jQM团队报告了这个问题。
$.mobile.widget.initSelector = ".selector";