I got a simple page filled with inputs and I need them to be printed with the content typed by user.
So far I can print the input fields but always empty inside.
class VM{
PrintDiv() {
let self = this;
var printContents = document.getElementById('print').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
location.reload();
}
}
ko.applyBindings(new VM);
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div id="print">some text<input /></div>
<br />
<button data-bind="click: PrintDiv">Print</button>