Last active
June 28, 2018 21:06
-
-
Save rg3915/0b78e32a42eed04581805262707ccc31 to your computer and use it in GitHub Desktop.
Print on HTML with JS e imprimindo gráfico ChartJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function printDiv(divName) { | |
var printContents = document.getElementById(divName).innerHTML; | |
var originalContents = document.body.innerHTML; | |
document.body.innerHTML = printContents; | |
window.print(); | |
document.body.innerHTML = originalContents; | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/14167041/802542 | |
var target = '{% url "candidate_fit_chart" cand_name=user.first_name pk=user.pk %}'; | |
$('#cand_fit').load(target); | |
$(document).on('click', '#print_btn', function(event) { | |
var printWindow = window.open(target, 'Print') | |
printWindow.addEventListener('load', function() { | |
printWindow.print(); | |
printWindow.close(); | |
}, true) | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment