我试图在打印一个JSF页面之前使用jQuery打印预览插件来显示它的预览。
首先,我尝试了一个带有普通HTML标签的演示。
<script src="../js/jquery.print-preview.js" type="text/javascript"
charset="utf-8"></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(function() {
alert("hai");
/*
* Initialise print preview plugin
*/
$j('.print-preview').printPreview();
alert("bye");
});
</script>
<div id="header" class="container_12">
<a class="print-preview">Print this Page</a>
</div> 我正确地工作,打印的-preview模式dailog被打开。
但是,当我尝试将<a>标记替换为<h:commandLink>时,不会触发print-preview.js中的$(this).bind('click', function(e)。
<h:form id="printForm">
<script src="../js/jquery.print-preview.js" type="text/javascript"
charset="utf-8"></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(function() {
alert("hai");
/*
* Initialise print preview plugin
*/
$j('.print-preview').printPreview();
alert("bye");
});
</script>
<div id="header" class="container_12">
<h:commandLink id="sample" value="Print this page" styleClass="print-preview"/>
</div>
</h:form>我甚至尝试过使用$j('printForm\\:sample').printPreview();,但它仍然不起作用。
我做错了什么吗?
发布于 2013-10-25 09:20:31
我用<p:commandLink>代替了<p:commandLink>,现在jQuery打印预览插件工作得很好。
https://stackoverflow.com/questions/19542068
复制相似问题