2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-17 19:21:23 +03:00

Hopefully a fix for #12364

* register the callback before invoking the toggling
* listen for `hidden` instead of `hide`
* account for the possibility of the associated `show` event being preventDefault-ed

Adds relevant unit tests.
This commit is contained in:
Chris Rebert
2014-05-19 01:25:52 -07:00
parent 7d75734e10
commit b058c018eb
2 changed files with 57 additions and 3 deletions
+6 -3
View File
@@ -268,10 +268,13 @@
if ($this.is('a')) e.preventDefault()
Plugin.call($target, option, this)
$target.one('hide.bs.modal', function () {
$this.is(':visible') && $this.trigger('focus')
$target.one('show.bs.modal', function (showEvent) {
if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
$target.one('hidden.bs.modal', function () {
$this.is(':visible') && $this.trigger('focus')
})
})
Plugin.call($target, option, this)
})
}(jQuery);