question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set data-clipboard-target's value after ajax?

See original GitHub issue

Hello,

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:closed
  • Created 8 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

27reactions
zenorochacommented, Feb 8, 2017

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.

18reactions
leandroafonsocommented, Feb 8, 2017

This is a powerful but crippled tool. Made to work just the way the author finds it interesting to use.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found