harryhorn/jquery-popover — Issue #4: closeEvent gets called for each popover instance
Author: ragulka
Created: 2012-02-18 11:49:21+00:00
State: open

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.