Skip to content

Instantly share code, notes, and snippets.

@smallmake
Last active August 29, 2015 14:20
Show Gist options
  • Save smallmake/11e14018363d69fe7a00 to your computer and use it in GitHub Desktop.
Save smallmake/11e14018363d69fe7a00 to your computer and use it in GitHub Desktop.
JQuery: Bootstrap popover のcontent htmlの手動セットとcloseボタン設置
# samenames_html is html to display in popover
if (samenames_html.length > 0) {
$("#popoverSameNames").popover({
title: '同姓同名があります.<span class="close">&times;</span>',
template: '<div class="popover" role="tooltip" style="width:500px;font-size:80%;"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"><div class="data-content"></div></div></div>',
html: true
}).on('shown.bs.popover', function(e){
var popover = $(this);
$(this).parent().find('div.popover .close').on('click', function(e){
popover.popover('hide');
});
});
$("#popoverSameNames").data('bs.popover').options.content = samenames_html;
$("#popoverSameNames").popover('show');
} else {
$("#popoverSameNames").data('bs.popover').options.content = "";
$("#popoverSameNames").popover('hide');
}