I've included fabric like so: <script src="js/fabric_freedrawing.js"></script>
But when I use it like this:
var canvas;
function initSketchPad() {
canvas = new fabric.Canvas('sketch-pad', {
isDrawingMode: true
});
}
I get
Uncaught TypeError: fabric.Canvas is not a constructor
I've included fabric like so: <script src="js/fabric_freedrawing.js"></script>
But when I use it like this:
var canvas;
function initSketchPad() {
canvas = new fabric.Canvas('sketch-pad', {
isDrawingMode: true
});
}
I get
Share Improve this question asked Aug 30, 2016 at 11:50 JordyvDJordyvD 1,6151 gold badge21 silver badges46 bronze badgesUncaught TypeError: fabric.Canvas is not a constructor
2 Answers
Reset to default 3I'm not sure what you have in your fabric_freedrawing.js
file but adding your code to a snippet below seems to work just fine.
var canvas;
function initSketchPad() {
canvas = new fabric.Canvas('sketch-pad', {
isDrawingMode: true
});
}
initSketchPad();
canvas {
border:1px solid;
}
<script src="https://cdnjs.cloudflare./ajax/libs/fabric.js/1.6.4/fabric.min.js"></script>
<canvas height=300 width=300 id="sketch-pad">
your version of fabric.js isnt up to date all just not working well all u gotta do is download a new one simple just download it from here
https://cdnjs.cloudflare./ajax/libs/fabric.js/1.6.4/fabric.min.js