我的站点export.xhtml下面加载了mailListDialog.xhtml文件:
export.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" template="/templates/template.xhtml">
<ui:define name="window_title">eMember - #{messages['title_label']}
</ui:define>
<ui:define name="header_title">
<h:outputText value="eMember - #{messages['title_export_mail']}" align="center" rendered="#{exportController.type == 'MAIL'}"/>
</ui:define>
<ui:define name="content">
<h:form id="exportForm" style="height:100%">
<!-- more data -->
<p:commandButton onclick="PF('mailList').show()" value="#{messages['export_create_mail']}" update=":mailListForm"
rendered="#{exportController.type == 'MAIL'}"/>
</h:form>
<!-- Mail-List-Dialog -->
<ui:include src="/pages/secured/dialogs/mailListDialog.xhtml" />
</ui:define>
</ui:composition>
mailListDialog.xhtml看起来像:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
<h:outputScript library="primefaces" name="jquery/jquery.js"/>
<h:outputScript library="default" name="js/jquery.zclip.min.js"/>
<script type="text/javascript">
alert("init *" + $("#mailListForm\\:data").text() + "*");
$(document).ready(function(){
$('#copyButton').zclip({
path:"#{resources['default:js/ZeroClipboard.swf']}",
copy:$('#mailListForm\\:data').text(),
afterCopy: function()
{
console.log($("hallo55 *" + $("#mailListForm\\:data").text() + "*" + " was copied to clipboard"));
alert("hallo55 *" + $("#mailListForm\\:data").text() + "*");
}
})
});
</script>
<p:dialog header="Mailverteiler"
widgetVar="mailList" resizable="false" id="mailListDlg"
showEffect="clip" hideEffect="clip" modal="true" appendTo="@(body)">
<h:form id="mailListForm">
<p:commandButton id="copyButton" icon="ui-icon-copy"/><br></br>
<h:outputText id="data" value="#{exportController.mailList}"/>
</h:form>
</p:dialog>
如果我点击export.xhtml中的按钮,将显示对话框,我可以看到带有邮件列表的第一个警报的messageBox。但是,如果我点击copyButton,那么就会发生这种情况。
我尝试使用$(&#39; #copyButton&#39;)。zclip或$(&#39; #mailListForm \:copyButton&#39;)。zclip({但它们都不起作用。
有人知道如何解决这个问题吗?