我有一个jqm单选按钮,如下所示:
<div data-role="controlgroup" data-type="horizontal">
<h3>Type</h3>
<input type="radio" name="type" id="deposit_typeTotal" value="t" checked/>
<label for="deposit_typeTotal">Total</label>
<input type="radio" name="type" id="deposit_typeIndividual" value="i"/>
<label for="deposit_typeIndividual">Individual</label>
</div>
它是我目前在Android galaxy s2上测试的手机应用程序的一部分,这是我看到问题的地方。我从来没有能够在桌面上的谷歌浏览器中打破它。
我在此按钮上附加了一个点击事件,该事件调用了一个执行各种操作的功能,但我已对其进行修改以将标题更改为按钮的值以帮助我进行调试。
var type = $("#deposit input[name=type]:checked").val(); // Gets the value of the checked button
app.count++;$(".depositOrPayment").html(app.count+"/"+type); // Sets the title of the page
所以我看到的是函数被调用的次数/ t或i取决于我点击的按钮。但是,有时(特别是如果我快速单击按钮),我将未定义为按钮的值。一旦发生这种情况,无论我做多少次点击都会保持不确定状态。
有人有任何想法吗?
干杯
格雷厄姆
答案 0 :(得分:0)
点击与点击之间存在差异。水龙头有大约300毫秒的延迟(大约那个)。无论如何,你也可以绑定到水龙头&amp;在JQM中单击事件(虚拟鼠标事件)。
$('#element').on('tap', function() {
...
});
或
$('#element').on('click tap', function() {
...
});
阅读本文:http://phonegap-tips.com/articles/fast-touch-event-handling-eliminate-click-delay.html
所以 FastClick https://github.com/ftlabs/fastclick
查看What is the difference between the click and tap events?
这是http://phonegap-tips.com/articles/fast-touch-event-handling-eliminate-click-delay.html
编辑:我把它变成了一个wiki,希望有人能比我更好地回答它:)