Click on a button => Call Meteor Function => copy response to clipboard

We have the functionality to generate an invitation link. At this time the link is shown in a text area and we have two buttons, one for generate a link (that generates the link on the server with a Meteor.call and writes the response to the clipboard) and one that copies the content to the clipboard.

We now want only one button. Copying the text inside of an event is now problem using some createRange and execCommand magic but as soon as I put the same code inside of a window.setInterval or insode of a meteor.call callback it does not work anymore. has anyone any idea?

Hide your second button and manipulate its click by jquery .click in meteor.call success function. This way you can always get back to two buttons if you want to.

I have tried to place a second button but I cannot trigger a document.execCommand(‘copy’) or document.execCommand(‘cut’) within a meteor.callback, not even when triggering an external click event.