Skip to content Skip to sidebar Skip to footer

Bootstrap Popover Dismiss On Click: Works Fine In Desktop Browser But Not In Mobile Browser

So I have a web app that runs on nodeJS and uses bootstrap for the front-end. I have integrated some bootstrap popovers and they do the following: When the user clicks or taps on

Solution 1:

I believe iOS does not bind click events to html or body. Give something like this a try (Close a Twitter Bootstrap Popover when Clicking Outside):

$('[data-toggle="popover"]').popover();

$('body').on('click', function (e) {
    $('[data-toggle="popover"]').each(function () {
        //the 'is' for buttons that trigger popups//the 'has' for icons within a button that triggers a popupif (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
            $(this).popover('hide');
        }
    });
});

Hope this helps.

Post a Comment for "Bootstrap Popover Dismiss On Click: Works Fine In Desktop Browser But Not In Mobile Browser"