How to set data-clipboard-target's value after ajax?
See original GitHub issueHello,
Is it possible to set data-clipboard-target’s value after an ajax request? Because the value I need to copy would be created after an ajax request.
like below:
<!-- Target -->
<input id="foo" value=" ">
<!-- Trigger -->
<button class="btn" data-clipboard-target="#foo">
<img src="assets/clippy.svg" alt="Copy to clipboard">
</button>
$('.btn').click(function() {
$.ajax({
url: '/get_text',
type: 'POST',
dataType:'text'
}).done(function (resp){
$('#foo').attr('value', resp);
});
});
That is, I hope I can copy the value after I click button with an ajax request.
Thanks a lot!!
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Copy to clipboard after success in ajax call, works ...
var input = $('#textholder'); function copyPassword() { $. ajax({ type: 'GET', url: 'https://jsonplaceholder.typicode.com/todos/1', success: ...
Read more >How to Copying Content to Clipboard with JavaScript
new Clipboard('#but_copy'); Add data-clipboard-target attribute to the element which targets from where the text is being copied.
Read more >clipboard.js — Copy to clipboard without Flash
A pretty common use case is to copy content from another element. You can do that by adding a data-clipboard-target attribute in your...
Read more >Select and copy data to clipboard using jQuery - CodeRomeos
Select and copy the texts to the clipboard in a single click ... In the value attribute goes the data which will be...
Read more >target Event Property
The numbers in the table specify the first browser version that fully supports the property. Property. target, Yes, 9.0, Yes, Yes, Yes. Syntax....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

First of all, about this issue, I’m investigating the best way to include Ajax request on this, probably with a Promise-like API which will require a major version bump.
Secondly, what a sad comment @leandroafonso. I don’t know you understand how open source works. This a project that I maintain on my spare time, with super restricted resources. It’s intended to be a generic sugar layer on top of an existing API. It’s available for free and nobody is forced to use it. If it doesn’t fit your needs you have two options: 1) build your own 2) send a pull request. By offending an open source author you’re just discouraging their contributions. What you’re doing is distasteful.
This is a powerful but crippled tool. Made to work just the way the author finds it interesting to use.