关于doneFunction(Jquery)中的print函数有什么问题

时间:2014-11-18 04:36:22

标签: javascript jquery html asp.net printing

我尝试在列化功能完成后打印页面但是打印功能发生了2次,第一次在列化功能完成之前打印,第二次在列化功能完成时发生。你能帮助我吗?

这是我的代码

 <script>
    $(function () {
        var content_height = 856;   // the height of the content, discluding the header/footer
        var page = 1;               // the beginning page number to show in the footer
        function buildNewsletter() {
            if ($('#newsletterContent').contents().length > 0) {
                // when we need to add a new page, use a jq object for a template
                // or use a long HTML string, whatever your preference
                $page = $("#page_template").clone().addClass("page").css("display", "block");

                // fun stuff, like adding page numbers to the footer
                $page.find(".footer #lbl_pageNum").append(page);
                $page.find(".footer #lbl_pageNum2").append(page);
                //create label to recive data

                $("body").append($page);
                page++;

                // here is the columnizer magic
                $('#newsletterContent').columnize({
                    columns: 1,
                    target: ".page:last .content",
                    overflow: {
                        height: content_height,
                        id: "#newsletterContent",
                        doneFunc: function () {
                            console.log("done with page");
                            buildNewsletter();                                
                            printForm();                                
                        }
                    }
                });
            }
        }
        setTimeout(buildNewsletter, 1000);            
    });
    function printForm() {
        window.print();
    }
</script>

0 个答案:

没有答案