Here is an updated demo that does what you are trying to do:
Using this (the same) HTML:
<a href="#" data-copy="http://test.one.com/" class="copy">Copy Original Link</a>
<br />
<a href="#" data-copy="http://test.two.com/" class="copy">Copy Medium Link</a>
<br />
<a href="#" data-copy="http://test.three.com/" class="copy">Copy Web Link</a>
This script should work:
$("a.copy").on('click', function (e) {
e.preventDefault();
}).each(function () {
$(this).zclip({
path: 'http://www.steamdev.com/zclip/js/ZeroClipboard.swf',
copy: function() {
return $(this).data('copy');
}
});
});
Here is what I did. First off the alert
that you were adding via afterCopy
is actually the default, so you don't need to add extra code for that. Also the data-copy
attributes should be accessed via jQuery's data
function. Finally I put the SWF reference to the same host as the JavaScript (this might not be necessary depending on the
security code in the SWF but it seemed necessary to get the jsfiddle to work.