ZClip SWF does not align with button position if button position changes

1.2k views Asked by At

I am currently using the zclip/jquery code to allow copying to the clipboard. It is currently attached to a span button. It seems to use a swf file over the button to provide the flash based copy to clipboard feature. The problem that I have is that when I dynamically add new elements to the page, the button position moves down but the SWF position stays the same. Is there anything I can do to have the zclip "follow" the button? Zclip snippet below:

$("#copyToClip").zclip({
    path:'include/javascript/ZeroClipboard.swf',
    copy:function(){return $("#outputtext").text();}
});
2

There are 2 answers

1
Richard Scarrott On

I beleive you can call the 'show' method to refresh the position:

$('#copyToClip').zclip('show');

The site does say "it may not be 100% reliable in every instance." and although it doesn't sound like it'll be an issue in your case it might be worth noting that it won't resize itself if the button has changed size.

0
oldergod On

The zclip('show') thing actually calls the jquery show method, not the Zclip function.

An other tip would be to trigger the window resize or load event. You can see in the code the reposition function is bound to it.

      a(window).bind("load resize", function(){
        d.reposition()
      })

then everytime, I add/remove element to my page, I call

$(window).trigger('reload');

That does the trick for me.