I am trying to copy a simple URL which is bound to a button. The console successfully logs the data but it doesn't return the value to be pasted. Please note that the data-clipboard-text changes on an AJAX call. What am I doing wrong?
<button class="btn btn-success btn-sm pull-right" data-clipboard-text="pedigreetrail/eyJpdNkYWQxZDRkYjQzN2NkZWQ1MTQ4OTg2MiJ9/share" id="share-button">
<i class="fa fa-share" aria-hidden="true"></i>
</button>
new ClipboardJS("#share-button", {
text: function(trigger) {
console.log($(trigger).data('clipboard-text'));
return trigger.getAttribute('data-clipboard-text');
}
});