I'm importing an SVG file into my paper JS script with importSVG
and a callback function like below.
However, I'd like to use the item
variable that I imported outside of the scope of the callback function. I've tried using closures by encapsulating the load_svg
function in brackets. However, I couldn't get that to work. How do I get around this?
$(document).ready(function() {
paper.setup("myCanvas");
with (paper) {
var load_svg = function(item) {
console.log("imported SVG!");
};
var url = "http://localhost:3000/13.svg";
project.importSVG(url, {
expandShapes: true,
onLoad: load_svg()
});
}
});
Thanks!