Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling .popover('hide') prevents popover from open on next click #18860

Closed
KateHodge opened this issue Jan 12, 2016 · 6 comments
Closed

Calling .popover('hide') prevents popover from open on next click #18860

KateHodge opened this issue Jan 12, 2016 · 6 comments
Labels

Comments

@KateHodge
Copy link

Hi,

I think I've found a bug where by if you manually close a popover using the .popover('hide') method, it takes two clicks on the triggering element to show it again: it's as if it thinks the popover is still open and the first click is to toggle it closed. I'm entirely prepared to believe this isn't a bug and just that I've misunderstood how it should work!

I've created a fiddle to demonstrate the issue. The popover contains a button that when clicked, closes the popover using .popover('hide'). When you click the button to show the popover again, nothing happens. Clicking it a second time then does show the popover. The fiddle is here:

http://jsfiddle.net/fxqzn4xd/3/
(updated following automated error check)

Thanks
Simon

@twbs-lmvtfy
Copy link

Hi @sbhodge80!

You appear to have posted a live example (http://fiddle.jshell.net/fxqzn4xd/1/show/light/), which is always a good first step. However, according to Bootlint, your example has some Bootstrap usage errors, which might potentially be causing your issue:

  • line 84, column 9: W007: Found one or more <button>s missing a type attribute.
  • line 31, column 7: W013: Bootstrap version might be outdated. Latest version is at least 3.3.6 ; saw what appears to be usage of Bootstrap 3.3.5
  • line 35, column 7: W013: Bootstrap version might be outdated. Latest version is at least 3.3.6 ; saw what appears to be usage of Bootstrap 3.3.5

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@KateHodge
Copy link
Author

KateHodge commented Jan 12, 2016

I have corrected the errors. The revised example is here:

http://jsfiddle.net/fxqzn4xd/3/

Thanks

@cvrebert
Copy link
Collaborator

Duplicate of #16732.

@SamanChalian
Copy link

I have corrected the errors. The revised example is here:

http://jsfiddle.net/fxqzn4xd/3/

Thanks
Simon

Could you find a way to solve that issue?

@KateHodge
Copy link
Author

Hi, yes, I can't remember exactly what led me to this so can't credit it, but using the following code hooks into the hidden event to reset the popover's click state, which doesn't happen when you manually hide it:

        $('body').on('hidden.bs.popover', function (e) {
            var popoverData = $(e.target).data("bs.popover");
            if (popoverData) {
                popoverData.inState.click = false;
            }
        });

@SamanChalian
Copy link

$('body').on('hidden.bs.popover', function (e) {
var popoverData = $(e.target).data("bs.popover");
if (popoverData) {
popoverData.inState.click = false;
}
});

Hi Kate, Thank you so much. That works nice. 👍

@twbs twbs deleted a comment from SamanChalian Feb 27, 2020
@twbs twbs locked as resolved and limited conversation to collaborators Feb 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants