Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is html2canvas not defined?

If I'm calling this function, getting always "html2canvas is not defined".

makeScreenshot: function(button)
{
    debugger;
    html2canvas(document.body, {
        Uncaught ReferenceError: html2canvas is not defined
        onrendered: function(canvas) {
            document.body.appendChild(canvas);
        }
    });
},

but why? I have a class of it... like in tutorial written about it. Does anyone have a solution?

I suppose I need to include html2canvas here, but I don't know how.

Ext.define("TEST.controller.Desktop", {
    extend: "Ext.app.Controller",

    views: [
        "desktop.Desktop",
        //"desktop.TaskBar",
        "desktop.Toolbar",
        "desktop.DataprovidersDataView",
        "configuration.UploadFileWindow"
    ],

refs: [{
    ref: "viewport",
    selector: "viewport"
}, {
like image 357
r.r Avatar asked Aug 14 '13 12:08

r.r


2 Answers

Ext doesn't know anything about classes not defined as part of it's class system, you need to include the JS file using a script tag in your html.

like image 91
Evan Trimboli Avatar answered Nov 20 '22 11:11

Evan Trimboli


If it's a Node.js application, try importing using the following code in the JS file in which the function's used:

import html2canvas from 'html2canvas';
// Or
const html2canvas = require('html2canvas');

For react, vuejs, or Angular2+ applications, you can use the following in your JS or TS file:

import html2canvas from 'html2canvas';
like image 1
Muskan Khedia Avatar answered Nov 20 '22 12:11

Muskan Khedia