Foundation.utils.debounce事件被触发时

问题描述:

我需要的是一种在这个代码页面中显示一个消息的方法,声明他们只能每30秒提交一个注释,但是我看不到任何方法来实现这一点。隐藏的回调或事件我可以挂钩?Foundation.utils.debounce事件被触发时

 $body.on('keypress', '.commentForm textarea', Foundation.utils.debounce(function (event) { 
     var $wrapper = $(this).parentsUntil('.confession_comments_element').parent(); 
     var $self = $(this); 
     var $commentWrapper = $self.parent().parent().parent(); 

     if (event.which === 13) { 
      if ($commentWrapper.find('.confession_comment_wrapper').length) { 
       $self.parent().parent().ajaxSubmit({ 
        'success': function (data) { 
         $commentWrapper.find('.confession_comment_wrapper').append(data); 
         $self.val(''); 
        } 
       }); 
       return true; 
      } 
      $self.parent().parent().ajaxSubmit({ 
       'success': function (data) { 
        $commentWrapper.append(data); 
       } 
      }); 
      return false; 
     } 
    }, 30000, true)); 

我想你可以在成功提交后禁用POST按钮,并启动一个30秒的计时器,然后再次启用它。例如:

 $self.parent().parent().ajaxSubmit({ 
     'success': function (data) { 
      $commentWrapper.append(data); 

      $('#your_post_button').addClass('disabled'); 
      setTimeout(function() { 
       $('#your_post_button').removeClass('disabled'); 
      }, 30000); 

     } 
    }); 
+0

其实你只是提醒我说,我的方法不会工作,我的方法只会在用户在整个30分钟内呆在页面上时才起作用。我需要处理这个服务器端。 –