So, I have this simple code
$('#info_name'+index).show("slide", {direction: "right"}, 1000, function(){
$('#info_info'+index).show('slide',{direction: "up"}, 1000);
});
The i is declared upper as just a variable var i=0, but in callback, function I can’t see it…
There is a scope issue with
i. Sinceiis declared in the outer scope, all callbacks will reference the samei, meaning, ifiis changed, all callbacks’ references toiwill also be changed.What you can do is to create a function to generate the callback, since a new scope is created in that case, the value of
iwill be preserved.Based on the original question, I simplified the code a little bit. You’ve since edited it, and I can’t find the callback anymore… but hope this might help ya
JSFiddle: http://jsfiddle.net/vd9Mj/
UPDATE:
Where’s your callback…? It seems you’ve removed it from the question.