Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquerymobile+;主干tap事件触发两次_Jquery_Jquery Mobile_Backbone.js_Touch Event - Fatal编程技术网

jquerymobile+;主干tap事件触发两次

jquerymobile+;主干tap事件触发两次,jquery,jquery-mobile,backbone.js,touch-event,Jquery,Jquery Mobile,Backbone.js,Touch Event,以下是我在视图中定义事件的位置: events : { "tap #exerciseProgressBarContainer" : 'progressBarClick' }, 以下是行动: progressBarClick : function() { // start? if(this.curWorkoutExercise.isTimed() && !this.curExerciseStartTi

以下是我在视图中定义事件的位置:

events : {
            "tap #exerciseProgressBarContainer" : 'progressBarClick'
        },
以下是行动:

    progressBarClick : function() {
        // start?
        if(this.curWorkoutExercise.isTimed() && !this.curExerciseStartTime) {
            HTMLHelper.endGlow(this.$('#exerciseProgressBarContainer .progressBar.overlay'));
            this.startExerciseProgressTimer();
        }
        // done?
        else {
            this.stopExerciseProgressTimer();

            // save the log
            this.addCurExerciseLog();

            this.startBreak();
            this.nextAction();
        }
    },
基本上,在第一次点击时,用户启动进度计时器,启动后,另一次点击完成。在我的iPhone和Android上发生的是点击事件触发两次,使进度条的开始和停止同时进行。你知道为什么会发生这种情况以及如何解决吗?注意:我已经尝试过用
vclick
交换
tap

非常感谢

为什么不使用“touchend”事件

顺便说一句,当你的脚本在运行时被激发而失败时,最好确保它在运行时不能被激发。如果有人因为不耐烦而贴了两次怎么办


在某些情况下,可以使用jquery的函数.one()来实现此目的。在大多数情况下,您需要更大的灵活性,您可以通过简单的变量检查来解决这个问题。

我使用
e.stopPropagation()
e.preventDefault()