fabricjs - fabric.loadSVGFromURL when called in a loop always call the last callback -


fabric.loadsvgfromurl when called in loop call last callback, , not callbacks in loop. looks closure issue in fabric loadsvgfromurl. code below print value 2 in console log tells callback invoked last iteration.

code

var paths = ['walking-0.svg', 'walking-1.svg', 'walking-2.svg']; (var = 0; < paths.length; i++) {     var path = paths[i];     fabric.loadsvgfromurl(path, (function (i) {         return function (objects, options) {             console.log(i); //always print 2, when expected behaviour print 3 number starting 0 2.             console.log(objects) //print once, when should print thrice         }     })(i)); } 


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -