0

I want to use this https://github.com/niklasvh/html2canvas but getting error after including its cdn like

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.js" type="text/javascript" xml="space"></script>

When I use it like

download : function() {
        html2canvas($("#result-box"), {
          scale: 2,
        onrendered: function(canvas) {

             var a = document.createElement('a');
             window.open(canvas.toDataURL("image/jpg"));
             a.href = canvas.toDataURL("image/jpg").replace("image/jpg", "image/octet-stream");
             a.download = 'lash-prescription.jpg';
             a.click();


     }
        });
    }

it says

 Uncaught ReferenceError: html2canvas is not defined
    at Object.download (my.js:269)

1 Answer 1

0

Look like you try to call function from js library when it doesn't loaded. Try to wrap your function in:

jQuery(document).ready(function($) {
  Your function here
});
1
  • I tried . but I read some where I need to put some require(['jquery'], function ($) { } like this type of representation ?
    – ephemeral
    Commented Feb 20, 2018 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.