Take the 2-minute tour ×

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(){

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?

share|improve this question
There are plenty of question on StackOverflow about closures already. Just search it: stackoverflow.com/search?q=%5Bjavascript%5D+closure –  PitaJ Aug 28 '12 at 18:07
add comment

closed as primarily opinion-based by Neal, j0k, ThinkingStiff, Qantas 94 Heavy, TimWolla Mar 2 at 23:31


1 Answer

up vote 1 down vote accepted

No, ini is a function per se, and therefore has its own scope. So, the arguments passed to ini on each call won't change, and another closure is not necessary.

share|improve this answer
add comment
