Skip to content

Instantly share code, notes, and snippets.

@zukilover
Last active June 8, 2016 07:59
Show Gist options
  • Save zukilover/4ba0542ef71a4a4b4a2227a7689e1fed to your computer and use it in GitHub Desktop.
Save zukilover/4ba0542ef71a4a4b4a2227a7689e1fed to your computer and use it in GitHub Desktop.
Initiate custom popover
$(s.customPopover).each(function () {
if (!$().popover) return;
var popover = $(this),
backdrop = popover.data('backdrop'),
content = popover.attr('href') || popover.data('popover-content'),
getHtml;
$(content).hide();
getHtml = function(){
return $(content).html();
}
popover.popover({
html : true,
content : getHtml,
trigger : 'manual'
})
.on('shown.bs.popover', function () {
$(document).on('click', '[data-dismiss=popover]', function(){
popover.popover('hide');
});
})
.on('show.bs.popover', function () {
if( backdrop ){
$('<div/>').addClass('modal-backdrop fade in').appendTo('body');
$('body').addClass('ovh');
}
})
.on('hidden.bs.popover', function () {
if( backdrop ){
$('.modal-backdrop').remove();
$('body').removeClass('ovh');
}
});
popover.on('click', function(e){
e.preventDefault();
popover.popover('show');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment