ryangjchandler/alpine-clipboard

$clipboard(dataelement) gives writeText error

ralphjsmit opened this issue · 1 comments

I'm implementing the clipboard on my website, but I can't get it to work. I did it like this:

<div x-data="{ markup: 'COPYME' }">
    <span @click="$clipboard(markup)" class="my-3 font-sans ...">Click to copy</span>
</div>

When I try to use it, it gives an error. My Chrome devtools gives the following error (see below). I concluded that the @click is working and that the $clipboard() property is working too (as the error occurred in the alpine clipboard file). Am I doing something wrong or is this a bug?

Many thanks!

Schermafbeelding 2021-03-25 om 16 52 32

Update:

Just after I posted this, I realised that my site wasn't using HTTPS. I remembered reading somewhere that a certain method for copying text only works on HTTPS, so when I tried that, it worked.

Sorry for the inconvenience and thanks! 🤭