【发布时间】:2014-04-22 01:23:48
【问题描述】:
我是移动编程新手,已经面临这个问题。
使用 jQuery mobile 时,只有像“click”这样的普通事件起作用,而像“tap”或“taphold”这样的移动事件不起作用。我错过了什么?我已经找到了一些关于在链接 jQuery 文件时使用正确顺序的提示,但我没有看到任何错误。
<script src="js/jquery.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<link rel="stylesheet" type="text/css" href="css/map.css"></link>
<script src="http://open.mapquestapi.com/sdk/leaflet/v0.1/mq-map.js?key=**"></script>
<script src="http://open.mapquestapi.com/sdk/leaflet/v0.1/mq-geocoding.js?key=**"></script>
<script src="js/index.js"></script>
<script src="js/jquery.mobile.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {
loading('show');
map = L.map('map', {
layers: MQ.mapLayer(),
center: [51.137140, 10.239258],
zoom: 6
});
$(document).on("tap", "#map", function(e) {alert("lel");} );
loading('hide');
};
</script>
另一方面,这是可行的:
$(document).on("click", "#map", function(e) {alert("lel");} );
【问题讨论】:
-
您不应该使用
$(document).on('pageinit', function() { ..而不是window.onload吗? -
不幸的是,这并没有改变什么
标签: jquery events jquery-mobile