Я пытаюсь использовать плагин предварительного просмотра jQuery, чтобы показать prieview страницы 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>
Я работаю правильно, и открывается модальный dailog печати -preview.
Однако, когда я пытаюсь заменить тег <a>
<h:commandLink>
$(this).bind('click', function(e)
внутри print-preview.js
не запускается.
<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 прекрасно работает.
<script>
на<h:outputScript>
?