I am using to implement copy to clipboard function. it should copy some text, but for now i want it to be anything really... but its not working at all.
I included in head:
<h:outputScript name="js/jquery.zclip.min.js" library="test" />
<script>
$(document).ready(function(){
$('a#copy').zclip({
path:'#{resource['/test/js/ZeroClipboard.swf']}',
copy:$('div#content').text()
});
});
</script>
and in JSF page i have an ordinary :
<a href="#" id="copy">COPY</a>
there are no errors in Chrome console but clicking the link doesn't do anything too. I really have no idea why it's not working. Big thanks for any suggestion.
---------- EDIT
The datagrid:
<p:dataGrid var="item" columns="3" rows="9" value="#{pictureManagementBean.pictures}" id="gallery" paginator="true">
<p:column>
<p:panel header="#{item.pictureName}" style="text-align:center; width:230px;">
<h:panelGrid styleClass="shortLink">
<p:graphicImage value="#{item.thumbnailDir}" width="200px" />
<a href="#" id="copy#{item.idpicture}">COPY</a>
<p id="copy#{item.idpicture}">LOREM IPSUM</p>
<p:mandLink value="Delete" action="#pictureManagementBean.removePicture(item.idpicture)}" update="@form"/>
</h:panelGrid></p:panel></p:column></p:dataGrid>
I am using https://github./patricklodder/jquery-zclip to implement copy to clipboard function. it should copy some text, but for now i want it to be anything really... but its not working at all.
I included in head:
<h:outputScript name="js/jquery.zclip.min.js" library="test" />
<script>
$(document).ready(function(){
$('a#copy').zclip({
path:'#{resource['/test/js/ZeroClipboard.swf']}',
copy:$('div#content').text()
});
});
</script>
and in JSF page i have an ordinary :
<a href="#" id="copy">COPY</a>
there are no errors in Chrome console but clicking the link doesn't do anything too. I really have no idea why it's not working. Big thanks for any suggestion.
---------- EDIT
The datagrid:
<p:dataGrid var="item" columns="3" rows="9" value="#{pictureManagementBean.pictures}" id="gallery" paginator="true">
<p:column>
<p:panel header="#{item.pictureName}" style="text-align:center; width:230px;">
<h:panelGrid styleClass="shortLink">
<p:graphicImage value="#{item.thumbnailDir}" width="200px" />
<a href="#" id="copy#{item.idpicture}">COPY</a>
<p id="copy#{item.idpicture}">LOREM IPSUM</p>
<p:mandLink value="Delete" action="#pictureManagementBean.removePicture(item.idpicture)}" update="@form"/>
</h:panelGrid></p:panel></p:column></p:dataGrid>
Share
Improve this question
edited Mar 31, 2017 at 20:48
Divyesh Kanzariya
3,7893 gold badges47 silver badges46 bronze badges
asked Sep 7, 2012 at 14:50
AtaisAtais
11.3k7 gold badges74 silver badges115 bronze badges
1 Answer
Reset to default 3This works for me:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml"
xmlns:f="http://java.sun./jsf/core" xmlns:h="http://java.sun./jsf/html">
<h:head>
</h:head>
<h:body>
<h:outputScript library="default" name="js/jquery-1.8.1.min.js"/>
<h:outputScript library="default" name="js/jquery.zclip.min.js"/>
<script type="text/javascript">
$(document).ready(function(){
$('a#copy-description').zclip({
path:"#{resource['default:js/ZeroClipboard.swf']}",
copy:$('p#description').text()
});
});
</script>
<a id="copy-description" href="#">Copy Description</a>
<p id="description">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque volutpat venenatis erat
eu convallis. Phasellus ut purus dui, in tristique ligula. Fusce a sodales ipsum.
Proin et modo lacus. Morbi eget lectus ante, sed interdum orci.
Nunc rutrum, enim in mattis bibendum, sapien ligula semper nisi, sed ullamcorper justo sem quis felis.
Duis vehicula arcu non felis convallis eleifend.
</p>
</h:body>
</html>
where the folder structure is like this:
-->resources/default/js/jquery.zclip.min.js
-->resources/default/js/ZeroClipboard.swf