Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why clipboard is blank? #288

Closed
we138 opened this issue Aug 8, 2016 · 9 comments
Closed

Why clipboard is blank? #288

we138 opened this issue Aug 8, 2016 · 9 comments

Comments

@we138
Copy link

we138 commented Aug 8, 2016

Hi guys! I try to use clipboard.js and I stumbled with strange behavior. I have this

<a class="chosen-single" tabindex="-1">
     <span>foobar</span>
</a>

and this
<button class="btn" id="copy-app-id" data-clipboard-target="a.chosen-single span">Copy</button>

but when I click on the button, nothing happens. Clipboard is empty. How fix it?

sorry for my bad English

@zenorocha
Copy link
Owner

Please share a JSFiddle, otherwise I cannot help. Thanks!

@vberkel
Copy link

vberkel commented Aug 22, 2016

@zenorocha my situation also produces a blank clip. The events output to console show correct Action, Text and Trigger but it clears the clipboard for me.

I created a fiddle for you https://jsfiddle.net/jfrwe4eh/1/. I'm guessing it's because of special characters.

@kafeltz
Copy link

kafeltz commented Aug 23, 2016

Try to remove the style="display:none" from textarea, for me it looks like a security from browser.

Maybe you need to position: absolute; left: bigNumber

@vberkel
Copy link

vberkel commented Aug 23, 2016

You were right, that works. Thank you.

@zenorocha
Copy link
Owner

zenorocha commented Aug 23, 2016

If you need to copy content but don't want to show an element on the UI you can use data-clipboard-text https://github.com/zenorocha/clipboard.js#copy-text-from-attribute or the imperative API https://github.com/zenorocha/clipboard.js#advanced-options

@RackunSec
Copy link

Hello, I still seem to have this issue. It sometimes copies a TAB or other large single white-space, but mostly doesn't overwrite what's in the clipboard. The event handler is working and your code in the console shows everything just fine, (Action, Text, Trigger all report just fine from on.success()), but nothing goes into the clipboard. I thought that the clipboard mechanism in my computer was screwed up because of Chrome/sharing and restarted the app and then the machine, but still does not work. I have also tested Firefox and it also does not work.

@zenorocha
Copy link
Owner

@weaknetlabs please share a reproducible example using JSFiddle

@RackunSec
Copy link

@zenorocha Sorry, it was definitely my computers at home. At work, it's working just fine. I remotely cleared my cache at home and made sure my CloudFlare proxy was in developer mode, but still happens at home. But here at work, I did the same and it's working! Sorry for the false alarm and thanks for the quick response! I need to look into why the clipboard was not working from Chrome at home.

@zenorocha
Copy link
Owner

Cool, thanks for answering back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants