8

I know it works even on this site but only when I trigger it via the h1 element, and I need to trigger it via an image (representing copy) but when I try it simply won't work. Here's my Javascript:

$('#copyTxt').click(function(){
       alert($('#Txt2Copy').text());
       $(this).zclip({
           path: '/scripts/js/ZeroClipboard.swf',
           copy: $('#Txt2Copy').text(),
           afterCopy: function(){
               alert($('#Txt2Copy').text() + " was copied to clipboard");
           }
       });
    });

The alert was just for me to make sure it reaches and it does it just won't copy, if I add the beforeCopy I do get a message there but it moves no further.

The id copyTxt has been moved to a span, an img, tr, td, and the table itself but it just WON'T work unless I fire the event from the H1. The HTML in which the image is:

<tr>
          <td><label for="navUrl">Navigation URL &nbsp;<img id="copyTxt" src="/images/copy.png"/></label></td>
          <td id="Txt2Copy"><?= $this->order["order"]["navigationUrl"] ?></td>
        </tr>
Reporter
  • 3,897
  • 5
  • 33
  • 47
Tsundoku
  • 9,104
  • 29
  • 93
  • 127
  • 4
    possible duplicate of [zclip not working inside table](http://stackoverflow.com/questions/8673681/zclip-not-working-inside-table) – Ryley Feb 07 '12 at 21:35
  • I'm certain it is actually. I just couldn't comment at that time. It's the same issue, but with solution! – bottleboot Feb 08 '12 at 16:28

3 Answers3

11

This is an absolute positioning problem. This question has been answered here:
zclip not working inside table

I had the same problem it is fixed now!

So in your case add a wrapper to your link, like this:

<div style="position:relative">
<img id="copyTxt" src="/images/copy.png"/>
</div>
Community
  • 1
  • 1
bottleboot
  • 1,659
  • 2
  • 25
  • 41
3

I have been having the same problem. In my case I found that zclip just wouldn't work if the click object was in a table cell. So the following html worked:

<a id="copy-button">Copy</a>

But this just wouldn't:

<table><tr><td><a id="copy-button">Copy</a></td></tr></table>

Using firebug I found out that the transparent flash window overlay is getting positioned in the wrong place on the page. When i found out where it was I could click on it and it worked ok. However, I don't understand why it is not positioned over the actual click object.

BobB
  • 31
  • 2
  • Using your advice, I did the same thing. My link is buried in a div and isn't working correctly either. Thanks for the tip!!! – Evik James Feb 28 '12 at 00:30
0

I am using this right now, and I think that the id "copyTxt" must be on a button or on and anchor tag. Have you tried that?

Tolke
  • 198
  • 1
  • 14