[英]zclip issue when assigning it to multiple links in hidden divs
I m using ZClip (http://www.steamdev.com/zclip/) to enable a 'copy to clipboard' feature on a webpage on multiple links. 我正在使用ZClip(http://www.steamdev.com/zclip/)在网页上的多个链接上启用“复制到剪贴板”功能。 I m facing 2 issues in this scenario:
在这种情况下,我面临2个问题:
I ve tried using the $('a.copy').zclip('remove');
我试过使用
$('a.copy').zclip('remove');
before initializing zclip on links. 在初始化链接上的zclip之前。 This feature is shown on the zclip website but it has not resulted in getting rid of the extra alert boxes.
此功能显示在zclip网站上,但并未消除多余的警告框。 It only removes the swf associated with the links and not the events bound to the links.
它仅删除与链接关联的swf,而不删除绑定到链接的事件。 Basically I d like some guidance in how I can do either of the following:
基本上,我希望获得有关如何执行以下任一操作的指导:
Saganbyte, Saganbyte,
A couple of approaches come to mind. 我想到了几种方法。
First, let's assume the HTML of each of your four image/video/audio/documents divs is something like this: 首先,让我们假设四个图像/视频/音频/文档div的每个HTML都是这样的:
<div class="content" ...>
...
<input class="copyMe" /><!-- the element whose value is to be copied -->
</div>
Both approaches rely on a single "copy" button, which is visble when zClip is initialized: 两种方法都依赖于单个“复制”按钮,在初始化zClip时可见:
<a id="copy">Copy</a>
Your HTML is undoubtedly different but it should be fairly simple to adapt the ideas below to suit. 您的HTML毫无疑问是不同的,但是要适应以下想法,应该相当简单。
This solution relies on : 该解决方案依赖于:
class="copyWrapper"
, into which the "copy" button can be moved class="copyWrapper"
的空元素(例如span或div),可以将“ copy”按钮移动到其中 .copyWrapper
element each time a tab is clicked. .copyWrapper
元素中。 Initialize zClip as follows: 如下初始化zClip:
var $copyButton = $('a#copy').zclip({
path: 'js/ZeroClipboard.swf',
copy: function() {
return $(this).closest('div.content').find('.copyMe').val(); //$(this) is assumed correct
}
});
And initialize the tabs (assuming jQuery UI "tabs") as follows : 并按如下所示初始化标签(假设jQuery UI为“标签”):
$(".selector").tabs({
...
show: function(event, ui) {
$(ui.panel).find('.copyWrapper').append($copyButton);
}
});
This solution relies on : 该解决方案依赖于:
Initialize zClip as follows: 如下初始化zClip:
$('a#copy').zclip({
path: 'js/ZeroClipboard.swf',
copy: function(){
return $('.content:visible').find('.copyMe').val();
}
});
This solution relies on : 该解决方案依赖于:
javascript: JavaScript的:
$(".selector").tabs({
...
show: function(event, ui) {
var $panel = $(ui.panel);
if(!$panel.data('zClip_initialized')) { //If zClip not initialized in theis panel, then initialize it.
$('a.copy').zclip({
path: 'js/ZeroClipboard.swf',
copy: function() {
return $(this).closest('tr').find('.....').val();//Lots of guesswork here. You should have written this already.
}
});
$panel.data('zClip_initialized', true);//Raise a boolean flag to indicate that zClip is already initialized
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.