多次单击链接标记时防止显示错误

时间:2017-10-30 14:26:52

标签: php laravel-5

我的问题是:如何防止应用程序抛出

  

在null

上调用成员函数destroy()
当快速/双击laravel项目上的链接HTML元素时,用户浏览器上的

$('form').submit(function (event) {
    if ($(this).hasClass('submitted')) {
        event.preventDefault();
    } else {
        $(this).find(':submit').html('<i class="fa fa-spinner fa-spin"></i>');
        $(this).addClass('submitted');
    }
});

对于表单提交按钮的类似问题,我使用了kjdion84&#39; s answer

$('a.btn-danger').click(function () {
    if ($(this).hasClass('pressed')) {
        event.preventDefault();
    } else {
        $(this).addClass('pressed');
    }
});

但是我试过的改编并没有成功,无论是使用class还是id选择器:

event.preventDefault()

我还尝试了this更简单的答案,但dblclick似乎无法正常工作,使用@Component class SomeComponent { constructor(private currConvertPipe: CurrConvertPipe ) { } method() { this.convertedPrice = this.currConvertPipe.transform(this.Price, this.selectedCurrency, this.movieticket.price.currency); } } 并没有什么作用。

除了Javascript解决此问题之外,我还可以使用。

2 个答案:

答案 0 :(得分:0)

尝试返回false

 $('a.btn-danger').click(function () {

 if ($(this).hasClass('pressed')) {
        return false;
    } else {
        $(this).addClass('pressed');
    }

});

答案 1 :(得分:0)

是的,确定它对于具有类btn-danger的élément不起作用,但是它意味着任何具有btn-danger的éléments都有作为元素的父级。我将édit我的回复谢谢

相关问题