I\'ve successfully installed clipboard.js and have gotten snippets of text to copy to the clipboard upon click. I\'m going to be nesting these snippets of text (or the \"btn
Seems like all you want to do is integrating Clipboard.js with a Tooltip solution.
So here's how you can accomplish that using Bootstrap's Tooltip.
// Tooltip
$('button').tooltip({
trigger: 'click',
placement: 'bottom'
});
function setTooltip(btn, message) {
$(btn).tooltip('hide')
.attr('data-original-title', message)
.tooltip('show');
}
function hideTooltip(btn) {
setTimeout(function() {
$(btn).tooltip('hide');
}, 1000);
}
// Clipboard
var clipboard = new Clipboard('button');
clipboard.on('success', function(e) {
setTooltip(e.trigger, 'Copied!');
hideTooltip(e.trigger);
});
clipboard.on('error', function(e) {
setTooltip(e.trigger, 'Failed!');
hideTooltip(e.trigger);
});