Skip to content

Instantly share code, notes, and snippets.

@zulfajuniadi
Last active September 11, 2016 07:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zulfajuniadi/7672430 to your computer and use it in GitHub Desktop.
Save zulfajuniadi/7672430 to your computer and use it in GitHub Desktop.
Add Callback to bootstrap popover
/* override bootstrap popover to include callback */
var showPopover = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function() {
showPopover.call(this);
if (this.options.showCallback) {
this.options.showCallback.call(this);
}
}
var hidePopover = $.fn.popover.Constructor.prototype.hide;
$.fn.popover.Constructor.prototype.hide = function() {
if (this.options.hideCallback) {
this.options.hideCallback.call(this);
}
hidePopover.call(this);
}
/* usage */
/*
$('#example').popover({
showCallback : function() {
console.log('popover is shown');
},
hideCallback : function() {
console.log('popover is hidden');
}
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment