printing - jquery - How to properly copy data from div to new window dynamically -
i have problem. im trying create simple print preview when user clicks print preview
button open new window , copies data wanted. there elements checkbox don't want include im able successfully. problem when new window loaded original div altered. checkboxes removed in original div , print
button appears.
i want original div divdata
remain same. don't have problem new window.
btw jquery codes below:
$("#btnprintpreview").click (function () { var printcontents = new $("#divdata"); var mywindow = window.open("", "popup","width=1000,height=600,scrollbars=yes,resizable=yes," + "toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0"); var doc = mywindow.document; doc.open(); $(printcontents).find(".tcheckboxes").remove(); var button = "<input type='button' id='btnprint' value='print' style='float: right;' onclick='window.print();'/>"; $(printcontents).append($(button)); doc.write($(printcontents).html()); doc.close(); });
to see demo here link http://jsfiddle.net/du7et/.
ps: please check main div after clicking print preview
.
please me....
for wanting change following line to:
// before: var printcontents = new $("#divdata"); // after: var printcontents = $("#divdata").clone();
see http://api.jquery.com/clone/ further reference.
Comments
Post a Comment