Skip to content

Instantly share code, notes, and snippets.

@martdn
Last active February 5, 2016 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martdn/f09339d47663491ef002 to your computer and use it in GitHub Desktop.
Save martdn/f09339d47663491ef002 to your computer and use it in GitHub Desktop.
Bootstrap Tooltip within Popover
<div class="container">
<button id="popover1" type="button" class="" data-placement="bottom">on click</button>
<!-- Popover content 1-->
<div id="popoverContent1" style="display: none">
<form>
<div class="form-group has-error">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" placeholder="Email">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
<div id="messageTooltip1" style="display:none;">Вы не ввели email</div>
//function tooltip
var myTooltip = function() {
$('.has-error input').tooltip({
placement: 'left',
title: function() {
return $('#messageTooltip1').text();
}
}).tooltip('show'); //Display the tooltip element
};
jQuery(document).ready(function(){
// popover
$("#popover1").popover({
html : true,
trigger : 'click',
content: function(){
return $('#popoverContent1').html();
}
});
// show tooltip
$('#popover1').on('shown.bs.popover', function () {
myTooltip();
});
// remove class ".tooltip"
$('#popover1').on('hide.bs.popover', function () {
$('.tooltip').remove();
});
});
@martdn
Copy link
Author

martdn commented Feb 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment