Skip to content

Commit

Permalink
added ability close current popover in document
Browse files Browse the repository at this point in the history
  • Loading branch information
harryhorn committed Jul 2, 2011
1 parent 94db087 commit 12103fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.rdoc
Expand Up @@ -103,6 +103,10 @@ You can programmatically open and close a popover by using the following:

$('#button').trigger('hidePopover');

To close the currently open popover, for example from the cancel button of a popup dialog, do the following:

$(document).trigger('hidePopover');

== Popover styling

The popover style provided in popover.css is a basic style to mimic the iPad popover look & feel but you can style it anyway you like.
Expand Down
7 changes: 6 additions & 1 deletion jquery.popover.js
Expand Up @@ -30,7 +30,7 @@

settings.triangle$ = $('.triangle', settings.popover$);

// Document click closes active popover
// document click closes active popover
$.fn.popover.openedPopup = null;
$(document).bind("click", function(event) {
if ($.fn.popover.openedPopup != null
Expand All @@ -40,6 +40,11 @@
}
});

// document hidePopover causes active popover to close
$(document).bind("hidePopover", function(event) {
$.fn.popover.openedPopup.trigger('hidePopover');
});

// keyboard callback
function keyDown(event) {
if (!event.altKey && !event.ctrlKey && !event.shiftKey) {
Expand Down

0 comments on commit 12103fc

Please sign in to comment.