【发布时间】:2013-01-02 21:47:01
【问题描述】:
我的索引页面上有一个非常简单的用例。
<script src="js/jquery-min.js"></script>
<script src="js/jquery-mobile.js"></script>
<script type="text/javascript" src="cordova-2.2.0.js"></script>
<script>
$("body").on("swipeleft", function(event) {
alert('hello');
/*window.location.href = "html/first.html";*/
});
</script>
由于某种原因,此事件触发了 2 次。现在我确定我没有在 body 标记上绑定另一个事件,因为这是第一页。我也尝试过其他简单的事件,比如 touchstart 等。它们都触发了两次。我做错了什么?
更新:-
我已通过以下方式修改了我标记为正确的答案并且它有效。此页面上的事件不会触发两次。
<head>
<script type="text/javascript" src="js/jquery-min.js"></script>
<script>
$(document).bind("mobileinit", function() {
$.mobile.autoInitializePage = false;
$.mobile.defaultPageTransition = 'none';
$.mobile.touchOverflowEnabled = false;
$.mobile.defaultDialogTransition = 'none';
$.mobile.loadingMessage = '' ;
});
</script>
<script type="text/javascript" src="js/jquery-mobile.js"></script>
<script type="text/javascript" src="cordova-2.2.0.js"></script>
</head>
【问题讨论】:
-
@Floradu88 :您对此感到抱歉。我尝试了一些解决方案,但还没有得到确切的答案。但我会标记我正在研究的那个。
-
你应该只标记正确的答案,不要标记不正确的答案
-
是的,但是我标记为正确的那个对它进行了一些更改。我会相应地更新答案。
标签: javascript jquery html css jquery-mobile