Block alerts after 3 seconds

I want to close all alert items on the page in 3 seconds. I could just do

window.setTimeout ( ->
    $('.alert-box').remove()
    return
), 3000

But this does not do the same as pressing the x button in a warning. He does not revive him. And since it was written somewhere, I would not want to rewrite it.

I tried

$('.alert-box').data('events')

to find registered handlers and maybe find a way to close the alert with animations, etc., but no luck with that. However, I also tried the FireQuery plugin, which also did not do this work.

I was hoping there was some method to close the warning, for example

Foundation.alert.close(jQuery object)

or something can you help me with this?

+3
source share
2 answers

, :

$(".alert-box a.close").click();

, . . 'click.fndtn.alert 'on' [alert] a.close'.

$(".alert-box a.close").trigger("click.fndtn.alert")
+2

! , .

, $(".alert-box").slideUp();, :

$(document).ready ->
  window.setTimeout ( ->
      $(".alert-box").slideUp();
      $(".alert-box a.close").click();
      return
  ), 15000
+2

All Articles