aboutsummaryrefslogtreecommitdiff
path: root/js/src/alert.js
diff options
context:
space:
mode:
authorfat <[email protected]>2015-05-13 12:48:34 -0700
committerfat <[email protected]>2015-05-13 12:48:34 -0700
commitf8b2569ec8956a1f4d09fe6fc9865bd200ecde43 (patch)
tree190263c441212d1ba91507d385fe3e6bc33e2614 /js/src/alert.js
parentdafdd180cd54a2e238fe715d8aeb83c07f385a18 (diff)
downloadbootstrap-f8b2569ec8956a1f4d09fe6fc9865bd200ecde43.tar.xz
bootstrap-f8b2569ec8956a1f4d09fe6fc9865bd200ecde43.zip
implement global dispose method
Diffstat (limited to 'js/src/alert.js')
-rw-r--r--js/src/alert.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/js/src/alert.js b/js/src/alert.js
index 57a59746a..eda74d706 100644
--- a/js/src/alert.js
+++ b/js/src/alert.js
@@ -20,6 +20,8 @@ const Alert = (($) => {
const NAME = 'alert'
const VERSION = '4.0.0'
const DATA_KEY = 'bs.alert'
+ const EVENT_KEY = `.${DATA_KEY}`
+ const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const TRANSITION_DURATION = 150
@@ -28,9 +30,9 @@ const Alert = (($) => {
}
const Event = {
- CLOSE : 'close.bs.alert',
- CLOSED : 'closed.bs.alert',
- CLICK : 'click.bs.alert.data-api'
+ CLOSE : `close${EVENT_KEY}`,
+ CLOSED : `closed${EVENT_KEY}`,
+ CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`
}
const ClassName = {
@@ -75,6 +77,11 @@ const Alert = (($) => {
this._removeElement(rootElement)
}
+ dispose() {
+ $.removeData(this._element, DATA_KEY)
+ this._element = null
+ }
+
// private
@@ -159,7 +166,7 @@ const Alert = (($) => {
*/
$(document).on(
- Event.CLICK,
+ Event.CLICK_DATA_API,
Selector.DISMISS,
Alert._handleDismiss(new Alert())
)