ボタンから zclip を削除する方法が必要です。これは、動的にロードされるためです。ロードするたびに、zlip の別のインスタンスが追加されているように見えるため、複数回コピーされます。
使用ガイドに従って zclip('remove') を試しましたが、うまくいきませんでした:
function zclipMe(){
$('#copySearch').zclip({
path: 'http://www.steamdev.com/zclip/js/ZeroClipboard.swf',
copy: function () {
return $(this).prev('.cvl0').text();
},
afterCopy: function(){
var theText = $(this).prev('.cvl0');
var thePosition = $(this).prev('.cvl0').position();
$('.copied').text('Copied!').fadeIn(150).delay(1200).fadeOut(200).css({'top': thePosition.top , 'left': thePosition.left , 'width': theText.width()+30 , 'height': theText.height()+30 , 'line-height': theText.height()+ 30 +'px'});
$(this).zclip('remove');
}
});
}
ご覧のとおり、コピーするテキストの上にボックスを重ねて、「コピー済み!」という単語を表示します。正常にコピーされたことを示すために、動的ボタンが読み込まれた回数に応じて複数回起動します。
ありがとう