diff options
| author | Jacob Thornton <[email protected]> | 2011-11-16 00:27:04 -0800 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2011-11-16 00:27:04 -0800 |
| commit | a6f055ee5e74e14ce28a5f3246d8132f680e63f5 (patch) | |
| tree | a4bdcf94491b559af838bde39f096eacff37e40f /js/bootstrap-alerts.js | |
| parent | 0c7a80c79bb9a2e1761b4af804050962aac2fe57 (diff) | |
| download | bootstrap-a6f055ee5e74e14ce28a5f3246d8132f680e63f5.tar.xz bootstrap-a6f055ee5e74e14ce28a5f3246d8132f680e63f5.zip | |
improve alert api - $("#fat").alert("close") should just work.
Diffstat (limited to 'js/bootstrap-alerts.js')
| -rw-r--r-- | js/bootstrap-alerts.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/js/bootstrap-alerts.js b/js/bootstrap-alerts.js index 37bb430aa..7c4b919f7 100644 --- a/js/bootstrap-alerts.js +++ b/js/bootstrap-alerts.js @@ -54,6 +54,7 @@ * ====================== */ var Alert = function ( content, options ) { + if (options == 'close') return this.close.call(content) this.settings = $.extend({}, $.fn.alert.defaults, options) this.$element = $(content) .delegate(this.settings.selector, 'click', this.close) @@ -62,7 +63,10 @@ Alert.prototype = { close: function (e) { - var $element = $(this).parent('.alert-message') + var $element = $(this) + , className = 'alert-message' + + $element = $element.hasClass(className) ? $element : $element.parent() e && e.preventDefault() $element.removeClass('in') @@ -92,7 +96,12 @@ var $this = $(this) if ( typeof options == 'string' ) { - return $this.data('alert')[options]() + var data = $this.data('alert') + + if (typeof data == 'object') { + return data[options].call( $this ) + } + } $(this).data('alert', new Alert( this, options )) |
