Copy after ajax response
jonaswebdev opened this issue · comments
Hi,
I'm trying to copy an ajax (axios) response value to clipboard using the syntax this.$clipboard(value)
, but no success.
my code snippet:
...
.then((response) => {
this.$clipboard(response.data.url);
}
...
PS: no errors on console.
ideas about how to fix it?
thanks in advance
I thinks this is a security limitation imposed by browsers. Copying to clipboard must be a direct reaction to a User interaction (a click, for example), and you loose that interaction->reaction flow when doing the ajax request.
I'd love to be wrong though, as I need to do this exact thing.
I thinks this is a security limitation imposed by browsers. Copying to clipboard must be a direct reaction to a User interaction (a click, for example), and you loose that interaction->reaction flow when doing the ajax request.
I'd love to be wrong though, as I need to do this exact thing.
how to do?
No way to do it, afaik
it also happens without ajax
here's my code sample:
<v-text-field
v-if="!isCopied"
:value="productLink"
@click:append="copyProductPath(productId)"
append-icon="mdi-content-copy"
/>
and function:
copyProductPath (productId) {
this.productPath(productId)
this.isCopied = this.$clipboard(this.productLink)
setTimeout(() => {
this.isCopied = false
}, 2000)
}
Any idea why this.$clipboard(this.productLink)
function does not work in this case?