2012-05-02 14 views
0

jquery printElementを使用して印刷するカラーボックスを取得しようとしています。問題は、このコードが動作しないことです。カラーボックスの読み込み中にすぐにon()をラップしないと、プリンタの印刷ダイアログが開きます。jquery - printelement()on click

それ以外の場合は、クリックしても印刷されません。私は、コンソールに $( "#のtoprintを")エラーが発生します。printElementは

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
<script type="text/javascript" src="js/jquery.printElement.js"></script> 
<link href="css/print.css" rel="stylesheet" type="text/css" media="print" /> 
<script type="text/javascript"> 
    $(document).ready(function(){ 
     $("#print-invoice").on("click", function(event){ 
      $('#toprint').printElement(); 
     }); 
    }); 
</script> 
+0

_ "それは動作しません" _は**決して**十分な問題の説明です。 –

答えて

0

関数ではありませんあなたのjquery.printelement.jsの適切なパスを与えられていない

$("#print-invoice").click(function(){ 
      $('#toprint').printElement({printMode: 'popup'}); 
     }); 
0

を試してみてください。あなたはこのようなあなたのjsの完全なパスを与える必要があります

<script type="text/javascript" src="${pageContext.servletContext.contextPath}/resources/js/jquery.printElement.js"></script>