[英]jquery delay doesn't count as animation
我正在嘗試使用承諾在單擊按鈕后制作動畫。 但無論我做什么,它仍然會讓我繼續點擊。
我正在展示一些 Bootstrap 表單驗證器類,然后將它們刪除。 像這樣:
messageEffect : function(container) {
return container.fadeIn(100).delay(1000).fadeOut();
},
$.when(this.messageEffect($container)).done(function() {
$container.empty();
$icon.remove();
$group.removeClass('has-feedback has-' + alertType);
});
我在一些東西之后調用這個名為“showAlert()”的函數,如果出現故障,我會在輸入字段下方顯示錯誤消息。
問題是,如果我繼續點擊和點擊,它會發送垃圾郵件,直到它們由於動畫而消失(當然)。
我嘗試使用('div-that-is-animating').is(':animated')
但沒有用,我仍然可以向它們發送垃圾郵件。
我還嘗試在調用這個“showAlert()”函數之前解除切換和單擊的綁定,但也沒有奏效。
是不是因為延遲(1000)沒有像動畫一樣計數? 或者我還能嘗試什么?
提前致謝。
看看這是否有效(假設您的按鈕 ID 是myButton
):
messageEffect : function(container) {
$('#myButton').attr('disabled', true);
return container.fadeIn(100).delay(1000).fadeOut();
},
$.when(this.messageEffect($container)).done(function() {
$('#myButton').attr('disabled', false);
$container.empty();
$icon.remove();
$group.removeClass('has-feedback has-' + alertType);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.