ZClip SWF does not align with button position if b

2019-06-24 04:04发布

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条回答
劫难
2楼-- · 2019-06-24 04:34

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.

查看更多
太酷不给撩
3楼-- · 2019-06-24 04:49

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.

查看更多
登录 后发表回答