Skip to content

Instantly share code, notes, and snippets.

@setola
Created March 26, 2014 10:06
Show Gist options
  • Save setola/9780121 to your computer and use it in GitHub Desktop.
Save setola/9780121 to your computer and use it in GitHub Desktop.
How to add a close button to the Twitter Bootstrap Popover feature
<a
id="children-age-toggler"
data-target-selector="#children-age"
data-placement="bottom"
href="javascript:;"
class="children-age popover-children"
data-title="Children's Age"
></a>
<div id="children-age" class="hidden">
<p>Please select your children's Age</p>
<!-- put here more html forms and stuff -->
</div>
// Popover for the quick search additional fields
jQuery('.popover-test').popover({
html : true,
content: function() {
return $(jQuery(this).data('target-selector')).html();
},
title: function(){
return jQuery(this).data('title')+'<span class="close">&times;</span>';
}
}).on('shown.bs.popover', function(e){
var popover = jQuery(this);
jQuery(this).parent().find('div.popover .close').on('click', function(e){
popover.popover('hide');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment