I have set up links that when clicked I want it to copy the text. It outputs many links so I have to make sure zClip copies the right one:
<a class="copy-callbacks" id="coupon-code-copy-<?php echo $couponid ; ?>" href="#"><?php echo $info['coupon'] ; ?></a>
This is the jQuery I am using but it is not working:
$(document).ready(function(){
$("a.copy-callbacks").zclip({
path:'scripts/ZeroClipboard.swf',
copy: $('#' + myCopyID).text(),
beforeCopy:function(){
var myCopyID = $(this).attr("id");
},
afterCopy:function(){
}
});
});
Using this code the flash object doesn't even load. I'm not quite sure what is going wrong. I've tried using:
copy: $(this).text(),
The flash object loads, but for some weird reason it copies some text in the footer. Any help is greatly appreciated!!
I've never had to use the .attr("id"), I always do the following.
<span class="swfTitle" style="position: relative; onmouseover="this.style.cursor='pointer'">
Text
</span>
$('.swfTitle').zclip({
path: '/js/ZeroClipboard.swf',
copy: function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
async: false,
data: JSON.stringify(PageInfo),
url: "dosomethinghere.aspx&query=string",
timeout: 30000,
success: function (data) {
PageInfo = JSON.parse(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
return PageInfo.PostHTML;
}
Where PageInfo is a js object. Overall, id tags are different than the class tags, .swfTitle is different than #swfTitle.