Last active
September 11, 2016 07:26
-
-
Save zulfajuniadi/7672430 to your computer and use it in GitHub Desktop.
Add Callback to bootstrap popover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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