如何在确认取消后防止进一步的jquery脚本

如何在确认取消后防止进一步的jquery脚本,jquery,confirm,Jquery,Confirm,我有一个脚本,在单击链接时打开确认框: html: <a href="validation/object_1/" class="validation">Validate</a> <a href="validation/object_2/" class="validation">Validate</a> 我有另一个jquery脚本,它加载一个等待的动画(一个非常复杂的脚本,我自己还没有编写,它包含在我的内容管理系统应用程序中) 当我点击链接时,确认

我有一个脚本,在单击链接时打开确认框:

html:

<a href="validation/object_1/" class="validation">Validate</a>
<a href="validation/object_2/" class="validation">Validate</a>
我有另一个jquery脚本,它加载一个等待的动画(一个非常复杂的脚本,我自己还没有编写,它包含在我的内容管理系统应用程序中)

当我点击链接时,确认弹出窗口打开,当我点击“取消”时,我不希望等待的动画运行

在单击“取消”后,如何防止运行任何进一步的jquery脚本

编辑:以下是加载动画的完整脚本:

    (function($) {

        $('.validation').on('click', function() {
  return confirm('Are you sure tou want to validate this ' + $(this).attr('href').split("/")[1] + ' ?');
});

    /**
       * Represents the loading animation.
       */
      Loadinganimation = function(context, settings) {
        this.settings = settings;
        this._init = function(context) {
          // Exclude subselectors.
          if (settings.subselector != '') {
            var subselectorSuffix = ' ' + settings.subselector;
          } else {
            var subselectorSuffix = '';
          }
          // Show on href click!
          if (Drupal.settings.jquery_loadinganimation.show_on_href) {
            // Exclude some further cases that shell not trigger.
            $(context)
                .find("a[href]" + settings.subselector)
                .not('a[href*="javascript:"]')
                .not('a[href^="#"]')
                //.not('a[target="_blank"]')
                .not(".validation")
            .not('a[href^="http://fdrav.sncf.fr/system/files"]')
                .not(".noLoadingAnimation")
            .not(".views-submit-button")
                .each(
                    function(i, element) {
                      // Only trigger links that have no js events registered.
                      if (typeof $(this).data("events") == 'undefined'
                          || jQuery.isEmptyObject($(this).data("events"))) {
                        $(this)
                            .click(
                                function(eventObject) {
                                  // Nicht bei Öffnen in neuem Tab (Strg+Klick)
                                  if (!eventObject.ctrlKey) {
                                    Drupal.behaviors.jquery_loadinganimation.Loadinganimation
                                        .show();
                                  }
                                });
                      }
                    });
          }

          // Show on form submit
          if (Drupal.settings.jquery_loadinganimation.show_on_form_submit) {
            // Only execute if no other js events are registered to prevent cases
            // where page is not being reloaded and layer does not close though.
            $(context).find("form" + subselectorSuffix).not(".noLoadingAnimation").not(".views-submit-button").not(".validation").submit(function() {
              Drupal.behaviors.jquery_loadinganimation.Loadinganimation.show();
              $(context).ajaxStop(function() {
                // Hide loading animation after ALL ajax events have finished
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
              });
            });
          }

          // Show on AJAX
          if (context == document) {
            // Global context!
            if (Drupal.settings.jquery_loadinganimation.show_on_ajax) {
              // Register loading animations for ajax events!
              $(context).ajaxStart(function() {
                // Show loading animation on request.
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.show();
              });

              $(context).ajaxStop(function() {
                // Hide loading animation after finish.
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
              });
            }
          }

          // Hide on animation click!
          if (Drupal.settings.jquery_loadinganimation.close_on_click) {
            $("div#loadinganimation").on('click', function() {
              Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
            });
          }

          // Hide on ESC press.
          if (Drupal.settings.jquery_loadinganimation.close_on_esc) {
            $(document).keyup(function(event) {
              var keycode = event.which;
              if (keycode == 27) { // escape, close box
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
              }
            });
          }
        };

        // Initialize!
        this._init(context);

        // Register global Drupal.behaviors.jquery_loadinganimation.Loadinganimation
        // object after init!
        Drupal.behaviors.jquery_loadinganimation.Loadinganimation = this;

        /**
         * Displays the loading animation.
         */
        this.show = function() {
          // Only show if not already shown.
          if ($("div#loadinganimation").length == 0) {
            $("body")
                .append(
                    '<div id="loadinganimation"><div class="loadinganimation-box"><div class="loadinganimation-outer"><div class="loadinganimation-inner">&nbsp;</div></div><span class="loading-text">'+ Drupal.t('Merci de patienter ...', {}, {context: "jquery_loadinganimation"}) +'</span></div></div>');
          }
        };

        /**
         * Hides the loading animation.
         */
        this.hide = function() {
          $("div#loadinganimation").remove();
        };
      };

      /**
       * Initialization
       */
      Drupal.behaviors.jquery_loadinganimation = {
        /**
         * Run Drupal module JS initialization.
         *
         * @param context
         * @param settings
         */
        attach : function(context, settings) {
          // Initialize general loading animation.
          Drupal.behaviors.jquery_loadinganimation.Loadinganimation = new Loadinganimation(
              context, settings.jquery_loadinganimation);
        }
      };


    })(jQuery);
(函数($){
$('.validation')。在('click',function()上{
返回确认('您确定要验证此'+$(this).attr('href').split(“/”[1]+'?”);
});
/**
*表示加载动画。
*/
Loadinganimation=函数(上下文、设置){
this.settings=设置;
this._init=函数(上下文){
//排除子选择器。
如果(settings.subselector!=''){
var subselector uffix=''+settings.subselector;
}否则{
var子选择器uffix='';
}
//显示在href点击!
if(Drupal.settings.jquery\u loadinganimation.show\u on\u href){
//排除shell未触发的其他一些情况。
$(上下文)
.find(“a[href]”+settings.subselector)
.not('a[href*=“javascript:]”)
.not('a[href^=“#”]”)
//.not('a[target=“\u blank”]”)
.not(“.validation”)
.not('a[href^='http://fdrav.sncf.fr/system/files"]')
.不是(“空载状态”)
.not(“视图提交按钮”)
.每个(
功能(一、元素){
//只有未注册js事件的触发器链接。
if(typeof$(this).data(“事件”)=“未定义”
||jQuery.isEmptyObject($(this.data(“事件”)){
$(本)
.点击(
函数(eventObject){
//neuem选项卡中的Nicht beiÖffnen(Strg+Klick)
如果(!eventObject.ctrlKey){
Drupal.behaviors.jquery\u loadinganimation.loadinganimation
.show();
}
});
}
});
}
//在表格上显示提交
if(Drupal.settings.jquery\u loadinganimation.show\u on\u form\u submit){
//仅在未注册其他js事件以防止发生案例时执行
//页面不会被重新加载,但图层不会关闭。
$(上下文)。查找(“表单”+子选择器uffix)。不(“.noLoadingAnimation”)。不(“.views提交按钮”)。不(“.validation”)。提交(函数(){
Drupal.behaviors.jquery_loadinganimation.loadinganimation.show();
$(上下文).ajaxStop(函数(){
//在所有ajax事件完成后隐藏加载动画
Drupal.behaviors.jquery_loadinganimation.loadinganimation.hide();
});
});
}
//在AJAX上显示
if(上下文==文档){
//全球环境!
if(Drupal.settings.jquery\u loadinganimation.show\u on\u ajax){
//为ajax事件注册加载动画!
$(上下文).ajaxStart(函数(){
//按要求显示加载动画。
Drupal.behaviors.jquery_loadinganimation.loadinganimation.show();
});
$(上下文).ajaxStop(函数(){
//完成后隐藏加载动画。
Drupal.behaviors.jquery_loadinganimation.loadinganimation.hide();
});
}
}
//隐藏动画点击!
if(Drupal.settings.jquery\u加载动画。单击时关闭){
$(“div#loadinganimation”)。在('click',function()上{
Drupal.behaviors.jquery_loadinganimation.loadinganimation.hide();
});
}
//按ESC键隐藏。
if(Drupal.settings.jquery\u loadinganimation.close\u on\u esc){
$(文档).keyup(函数(事件){
var keycode=event.which;
如果(keycode==27){//escape,则关闭框
Drupal.behaviors.jquery_loadinganimation.loadinganimation.hide();
}
});
}
};
//初始化!
这是._init(上下文);
//注册全局Drupal.behaviors.jquery\u loadinganimation.loadinganimation
//初始化之后的对象!
Drupal.behaviors.jquery\u loadinganimation.loadinganimation=this;
/**
*显示加载动画。
*/
this.show=函数(){
//仅在尚未显示时显示。
如果($(“div#loadinganimation”).length==0){
$(“正文”)
.附加(
''+Drupal.t('mercidepatienter…',{},{上下文:“jquery_loadinganimation”})+'';
}
};
/**
*隐藏加载动画。
*/
this.hide=函数(){
$(“div#loadinganimation”).remove();
};
};
/**
*初始化
*/
Drupal.behaviors.jquery\u加载动画={
/**
*运行Drupal模块JS初始化。
*
*@param上下文
*@param设置
*/
附加:功能(上下文、设置){
//初始化常规加载动画。
Drupal.behaviors.jquery\u loadinganimation.loadinganimation=新的loadinganimation(
context、settings.jquery\u loadinganimation);
}
};
})(jQuery);
    (function($) {

        $('.validation').on('click', function() {
  return confirm('Are you sure tou want to validate this ' + $(this).attr('href').split("/")[1] + ' ?');
});

    /**
       * Represents the loading animation.
       */
      Loadinganimation = function(context, settings) {
        this.settings = settings;
        this._init = function(context) {
          // Exclude subselectors.
          if (settings.subselector != '') {
            var subselectorSuffix = ' ' + settings.subselector;
          } else {
            var subselectorSuffix = '';
          }
          // Show on href click!
          if (Drupal.settings.jquery_loadinganimation.show_on_href) {
            // Exclude some further cases that shell not trigger.
            $(context)
                .find("a[href]" + settings.subselector)
                .not('a[href*="javascript:"]')
                .not('a[href^="#"]')
                //.not('a[target="_blank"]')
                .not(".validation")
            .not('a[href^="http://fdrav.sncf.fr/system/files"]')
                .not(".noLoadingAnimation")
            .not(".views-submit-button")
                .each(
                    function(i, element) {
                      // Only trigger links that have no js events registered.
                      if (typeof $(this).data("events") == 'undefined'
                          || jQuery.isEmptyObject($(this).data("events"))) {
                        $(this)
                            .click(
                                function(eventObject) {
                                  // Nicht bei Öffnen in neuem Tab (Strg+Klick)
                                  if (!eventObject.ctrlKey) {
                                    Drupal.behaviors.jquery_loadinganimation.Loadinganimation
                                        .show();
                                  }
                                });
                      }
                    });
          }

          // Show on form submit
          if (Drupal.settings.jquery_loadinganimation.show_on_form_submit) {
            // Only execute if no other js events are registered to prevent cases
            // where page is not being reloaded and layer does not close though.
            $(context).find("form" + subselectorSuffix).not(".noLoadingAnimation").not(".views-submit-button").not(".validation").submit(function() {
              Drupal.behaviors.jquery_loadinganimation.Loadinganimation.show();
              $(context).ajaxStop(function() {
                // Hide loading animation after ALL ajax events have finished
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
              });
            });
          }

          // Show on AJAX
          if (context == document) {
            // Global context!
            if (Drupal.settings.jquery_loadinganimation.show_on_ajax) {
              // Register loading animations for ajax events!
              $(context).ajaxStart(function() {
                // Show loading animation on request.
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.show();
              });

              $(context).ajaxStop(function() {
                // Hide loading animation after finish.
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
              });
            }
          }

          // Hide on animation click!
          if (Drupal.settings.jquery_loadinganimation.close_on_click) {
            $("div#loadinganimation").on('click', function() {
              Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
            });
          }

          // Hide on ESC press.
          if (Drupal.settings.jquery_loadinganimation.close_on_esc) {
            $(document).keyup(function(event) {
              var keycode = event.which;
              if (keycode == 27) { // escape, close box
                Drupal.behaviors.jquery_loadinganimation.Loadinganimation.hide();
              }
            });
          }
        };

        // Initialize!
        this._init(context);

        // Register global Drupal.behaviors.jquery_loadinganimation.Loadinganimation
        // object after init!
        Drupal.behaviors.jquery_loadinganimation.Loadinganimation = this;

        /**
         * Displays the loading animation.
         */
        this.show = function() {
          // Only show if not already shown.
          if ($("div#loadinganimation").length == 0) {
            $("body")
                .append(
                    '<div id="loadinganimation"><div class="loadinganimation-box"><div class="loadinganimation-outer"><div class="loadinganimation-inner">&nbsp;</div></div><span class="loading-text">'+ Drupal.t('Merci de patienter ...', {}, {context: "jquery_loadinganimation"}) +'</span></div></div>');
          }
        };

        /**
         * Hides the loading animation.
         */
        this.hide = function() {
          $("div#loadinganimation").remove();
        };
      };

      /**
       * Initialization
       */
      Drupal.behaviors.jquery_loadinganimation = {
        /**
         * Run Drupal module JS initialization.
         *
         * @param context
         * @param settings
         */
        attach : function(context, settings) {
          // Initialize general loading animation.
          Drupal.behaviors.jquery_loadinganimation.Loadinganimation = new Loadinganimation(
              context, settings.jquery_loadinganimation);
        }
      };


    })(jQuery);
$('.validation').on('click', function() {
  if (confirm('Are you sure you want to validate this ' + $(this).attr('href').split("/")[1] + ' ?'))
     {
       //Do your validation only if the user clicks okay.
     }else 
     {
       //If you have to manually turn off your animation do it here.  
     };
});