Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Snap work with templates

Tags:

snap.svg

index.html file as below: This HTML is compiled with Handlebars

<div id="svg"></div>

index.js file as below:

var s = Snap("#svg");
var bigCircle = s.circle(150, 150, 100);

When i executed my code. It is showing me following error:

TypeError: s.circle is not a function
like image 519
Ashwin Hegde Avatar asked Dec 25 '22 11:12

Ashwin Hegde


1 Answers

Your problem is that you are trying to attach Snap to a div element, instead of an SVG element.

Try changing

<div id="svg"></div> 

to

<svg id="svg"></svg> 

You can always put the svg inside a div.

like image 127
Ian Avatar answered Mar 12 '23 00:03

Ian