Search code examples
phpjqueryprintthis

How to force "PrintThis" to "Break page"


When i'm using Jquery pluggin "PrintThis",
The html function: <div style='page-break-after:always'></div>
stops working. Well, "PrintThis", won't break page!
How can i solve this?
Should i put the "Break line", in JS? How?
Is it ok to use the same table id?

HTML

//Print Btn
<button id="print_btn">btn</button>

//Table 1
<table id="table" class="display">
  <tr><td>Hi</td></tr>
</table>

//Break page here
<div style='page-break-after:always'></div>

//Table 2
<table id="table" class="display">
  <tr><td>Hi</td></tr>
</table>

JS

$(document).ready(function () {
    $('#print_btn').click(function () {
        $('#table').printThis();
    });
});

Solution

  • Well, once again the solution for this script was easy to solve. (Just had some sleep on it =)

    HTML

    //ADD class "display" and id.
    <div class="display" id "break_page" style='page-break-after:always'></div>
    

    JS

    //Add id "break_page" to JS
    $(document).ready(function () {
      $('#print_btn').click(function () {
        $('#table, #break_page').printThis();
      });
    });