Created
May 2, 2013 14:39
-
-
Save fxbeckers/5502657 to your computer and use it in GitHub Desktop.
Automatically init popovers on click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery popovers normally have to be initialized on a href with javascript. By hooking in to the click event instead, we can do the same without | |
// explicitely having to init, which is useful for pages with a dynamic dom | |
$(document).on('focusin click', '[data-toggle="popover"]', function (e) { | |
e.preventDefault(); | |
var $element = $(e.target); | |
if (!$element.has('[data-toggle="popover"]')) { | |
$element = $element.closest('[data-toggle="popover"]'); | |
} | |
($element).popover(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment