簡體   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