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

closeEvent gets called for each popover instance when pressing Esc #4

Open
ragulka opened this issue Feb 18, 2012 · 1 comment
Open

Comments

@ragulka
Copy link

ragulka commented Feb 18, 2012

Hey - first: great plugin! So far the best jQuery popover plugin I've found.

The issue I am facing is this: I'm trying to set focus to the button element after the popover is closed.
I have tried two different ways of doing this:

$(".popover-control1").popover({
    content : "#content1",
    closeEvent: function(btn) { btn.focus(); }
});
$(".popover-control2").popover({
    content : "#content2",
    closeEvent: function(btn) { btn.focus(); }
});

and

$(".popover-control1").popover({
                        content : "#content1"
}).bind('hidePopover', function() { $(this).focus(); });
$(".popover-control2").popover({
                        content : "#content2"
}).bind('hidePopover', function() { $(this).focus(); });

However, when I close the first popover, the focus is set to .popover-control2, nit .popover-control1 - in both cases.

The problem is that - in both cases, the closeEvent and 'hidePopover' are triggered for each popover instance, and thus - the focus is set to the last popover's button.

As far as I understand this is caused only when I press "Esc" on the keyboard to close the popover.

@ragulka
Copy link
Author

ragulka commented Feb 18, 2012

Okay, here's a solution I came up with - any comments/ideas welcome.

Replace line 275 with this:

                if ($.fn.popover.openedPopup != null)
                    $.fn.popover.openedPopup.trigger('hidePopover');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant