我想为ajax加载的结果(json数据,转换成html片段)启用zClip ...但是有一个问题,因为zClip自己附加了click事件...
$('ul.detail_list').delegate("a.clipboard", "click", function(e){
e.preventDefault();
$(this).zclip({
path:'images/ZeroClipboard.swf',
copy:$(this).text(),
afterCopy:function(){
window.open('....');
},
clickAfter: false
});我必须点击两次才能让Zclip开火。否则这段代码就会正常工作(如果我使用alert或console.log而不是zClip,它每次都会触发)……
那么,我如何才能附加Zclip来防止这种情况呢?
更新:忘记提到ul.detail_list是在json响应之后生成的html代码片段。
html代码片段(由json响应动态生成):
<ul class="detail_list">
<li><a href="#" class="clipboard">text to copy 1</a></li>
<li><a href="#" class="clipboard">text to copy 2</a></li>
...
</ul>谢谢!
发布于 2012-04-18 13:46:33
不确定它是否会有帮助,我会尝试这样做:
$("body").undelegate('ul.detail_list', "click", function(eventUndelegated) {
$('ul.detail_list').delegate("a.clipboard", "click", function(eventDelegated){
eventDelegated.preventDefault();
eventDelegated.stopPropagation();
$(this).zclip({
path:'images/ZeroClipboard.swf',
copy:$(this).text(),
afterCopy:function(){
window.open('....');
},
clickAfter: false
});
});
});https://stackoverflow.com/questions/10203119
复制相似问题