防止多次点击事件触发JQuery

这是场景,我的内容是基于类异步加载的.所以如果我有一个链接到类ajaxLink它触发如下:
$('a.ajaxLink').click(function (e) {
        e.preventDefault();
        var container = $(this).parents('div.fullBottomContent');
        var href = $(this).attr('href');
        container.fadeOut('fast',function () {
            $.ajax({
                url: href,dataType: "html",type: "GET",success: function (data) {
                    container.html(data);
                    BindEventHandlers();
                    container.fadeIn();
                    $.validator.unobtrusive.parse('form');
                },error: function () {
                    alert('An error has occurred');
                }
            });
        });

    });

全可爱现在在一个实例中,我想向用户显示一个警告,以确认他们想要加载页面,并松开所有的更改,以便我写过:

$('a.addANewHotel').click(function (e) {
        if (!confirm('Adding a new hotel will loose any unsaved changes,continue?')) {
            e.stopPropagation();
        }
    });

现在我已经尝试返回false,e.preventDefault()和e.stopPropagation();但无论第一种方法总是被触发?如何防止额外的点击事件触发?这是事件的顺序吗?

没有看到这是相关的,但我的HTML是:

<a style="" href="/CMS/CreateANewHotel?regionID=3&amp;destinationID=1&amp;countryName=Australia" class="button wideBorderlessButton ajaxLink addANewHotel">Add a new hotel</a>

最终解决方案如下:

$('a.addANewHotel').click(function (e) {
        if (!confirm('Adding a new hotel will loose any unsaved changes,continue?')) {
            e.stopImmediatePropagation();
            e.preventDefault();
        }
    });

解决方法

你尝试过:event.stopImmediatePropagation?

我相信这是你正在寻找的:

http://api.jquery.com/event.stopImmediatePropagation/

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...