1

我需要一种从按钮中删除 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');
       }
    });
}

如您所见,我在要复制的文本上覆盖了一个框,并带有“已复制!”一词 显示它已被成功复制,并且这会根据我的动态按钮已加载的次数而触发多次。

谢谢

4

1 回答 1

0

我也有同样的问题。我先解决删除事件尝试:$('#copySearch').unbind(); 如果您需要再次生成按钮

于 2014-07-03T09:54:29.847 回答