一:插件
ZeroClipboard.js
二:使用
<script type="text/javascript" src="plug-in/copy/ZeroClipboard.js"></script> //点击行时,给copycontent赋值
onClickRow:function(rowIndex,rowData){
rowid=rowData.id;gridname=‘signList‘;
var url=‘${prefix_link}‘+‘${sign_postfix_link}‘+rowData.weixinAccountid+‘&aw=${aw}‘;
$("#copycontent").val(url);
}
<a href="#" class="easyui-linkbutton" plain="true" icon="icon-edit" id="copylink">复制链接</a> <input type="hidden" id="copycontent" value="" /> $("document").ready(function(){ var client = new ZeroClipboard($("#copylink")); client.on("ready",function(event){ client.on( "copy", function (event) { var rowsData = $(‘#signList‘).datagrid(‘getSelections‘); if (!rowsData || rowsData.length==0) { tip(‘请选择复制行项目‘); return; } if (rowsData.length>1) { tip(‘请选择一条记录再复制‘); return; } if(rowsData[0].state == 0){ tip(‘活动未上线,复制失败‘); return; } var clipboard = event.clipboardData; clipboard.setData("text/plain", $("#copycontent").val()); //取copycontent的值
tip("复制成功"); }); }); });
时间: 2024-10-11 06:25:00