7

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

JordyvD
  • 1,565
  • 1
  • 18
  • 45

2 Answers2

3

I'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.com/ajax/libs/fabric.js/1.6.4/fabric.min.js"></script>
<canvas height=300 width=300 id="sketch-pad">
StefanHayden
  • 3,569
  • 1
  • 31
  • 38
0

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.com/ajax/libs/fabric.js/1.6.4/fabric.min.js

user4920718
  • 1,196
  • 1
  • 10
  • 13