我正在努力让 ZeroClipboard 在 jQuery 上下文中工作。我所追求的基本用法是剪切每个的文本div
与班级copy
单击时。
以下 jsFiddle 使用稳定的 ZeroClipboard v1.3.3 进行双击工作
http://jsfiddle.net/bEQ6R/ http://jsfiddle.net/bEQ6R/
html:
<div class="copy">Click this text to copy this text</div>
<div class="copy">Or click this text to copy this text</div>
<p class="debug flash-loaded">Flash player is loaded.</p>
<p class="debug confirm-copy">Text Copied.</p>
<textarea placeholder="Use this textarea to test your clipboard"></textarea>
js:
$(document).ready(function() {
ZeroClipboard.config({ moviePath: 'http://zeroclipboard.org/javascripts/zc/ZeroClipboard_1.3.2.swf',debug: true });
var client = new ZeroClipboard($('.copy'));
client.on('load', function(client) {
$('.flash-loaded').fadeIn();
client.on('complete', function(client, args) {
client.setText($(this).text());
// client.setText('Manually Set Text to This instead of the contents of the div');
console.log(client);
$('.confirm-copy').fadeIn();
});
});
});
是的,我知道这里还有其他类似的 ZeroClipboard 问题,但我还没有看到简单的 jsFiddle 版本实际工作。我遇到的现有小提琴要么已被弃用,要么因其他原因不再起作用。
另外,ZeroClipboard 在他们自己的网站上进行了演示http://zeroclipboard.org/ http://zeroclipboard.org/对于相同的版本似乎工作得很好,所以我知道这是可能的。