繁体   English   中英

jQuery Print Preview插件无法使用<h:commandLink>

[英]jQuery Print Preview Plugin not working with <h:commandLink>

我正在尝试使用jQuery Print Preview插件在打印前显示JSF页面的预览

首先,我尝试了一个带有纯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> 

我可以正常工作,并且可以打开print -preview模式模态日志。

但是,当我尝试将<a>标记替换为<h:commandLink> ,不会触发$(this).bind('click', function(e) 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(); ,但仍然无法正常工作。

难道我做错了什么?

我将<h:commandLink>替换为<p:commandLink> ,并且jQuery Print Preview插件现在可以正常工作了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM