单击一下,打印页面函数调用多次jquery

时间:2012-06-12 08:25:23

标签: duplicates live jquery die

$(document).ready(function() {

   $('#posHold tbody tr').die();
   $('#posHold tbody tr').live('click', function () {

   $(".btnPrint").printPage({
        url: "receipts/void.jsp?ID=111",
        message:"Your document is being created"
    });

    $('.btnPrint').trigger('click');

    });
 });

当我点击tr一次时,它会打印到打印机一次。当我再次点击tr时,它打印到打印机2次,然后下次点击3次等等.....即使我也在.live()之前调用.die()

我们如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

试试这个:

$(document).ready(function() {
   $('a.btnPrint').printPage({
        url: "receipts/void.jsp?ID=111",
        message:"Your document is being created"
    });
 });