From 5de1e39a8fba831faa170f46e868068fa069dd0e Mon Sep 17 00:00:00 2001 From: Jonathan Ingram Date: Thu, 22 Dec 2011 16:41:26 +1100 Subject: [PATCH 1/2] From #822 --- js/bootstrap-alert.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 90961cdd39..1ce8f01bff 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -39,6 +39,8 @@ , selector = $this.attr('data-target') || $this.attr('href') , $parent = $(selector) + $parent.trigger('close') + e && e.preventDefault() $parent.length || ($parent = $this.hasClass('alert-message') ? $this : $this.parent()) @@ -47,6 +49,8 @@ function removeElement() { $parent.remove() + + $parent.trigger('closed') } $.support.transition && $parent.hasClass('fade') ? From 2ebc0ad2ef13c4eb9ab2e7b57ff6ca661687ca4e Mon Sep 17 00:00:00 2001 From: Jonathan Ingram Date: Thu, 22 Dec 2011 16:47:42 +1100 Subject: [PATCH 2/2] Update docs to show available events on alert --- docs/javascript.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/javascript.html b/docs/javascript.html index bf27dd7f17..0bdcdc8ed5 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -750,6 +750,30 @@ $('a[data-toggle="tab"]').on('shown', function (e) {

.alert('close')

Closes an alert.

$(".alert-message").alert('close')
+

Events

+

Bootstrap's alert class exposes a few events for hooking into alert functionality.

+ + + + + + + + + + + + + + + + + +
EventDescription
closeThis event fires immediately when the close instance method is called.
closedThis event is fired when the alert has been closed (will wait for css transitions to complete).
+
+$('#my-alert').bind('closed', function () {
+  // do something ...
+})

Demo

×