iD is an object that changes on every iteration in a loop. Also in this loop I run the following:
$("td.item_holder > div").append(dynamo.shop.box.ini(item_info,(function(data){
return function(){
console.log(data);
}
})(iD)));
I’m hoping that this forms a closure. My only query is, the function it calls dynamo.shop.box.ini uses .bind (jQuery) as such:
ini : function(data,callback){
....
var right = $('<div>').addClass("dynamo_right").html('bye').bind('click',callback);
....
return container;
},
Do I need to use another anonymous function on the .bind call to keep the closure?
No,
iniis a function per se, and therefore has its own scope. So, the arguments passed toinion each call won’t change, and another closure is not necessary.