I have two containers, each triggers some function, which has to pass the object reference.
The function has nested queue and setTimeout, and I need to pas an object reference through both of them, to execute it on the right object.
This is what I tried:
var pimg=parent.find('.prod_img'); // This is the object I actually need to pass;
pimg.children('img:last').queue((function(aaa){
return function() {
whatthe= (function (itema) {
return function() {
itema.children('img').each(function(){
alert(itema.attr('id'));
//alert used for debug.
$(this).stop(false,false).animate({opacity:0},400,function(){
});
});
}
})(aaa)
aaa.data('timeout',window.setTimeout("whatthe()", 400));
}
})(pimg)
);
Now what happens is that if I trigger this function on both of my objects quickly, it would alert the same ID, which suggests that it never passes the object reference.
Note, the pimg is the actual object, it is then called aaa in queue reference, and then itema in the setTimeout reference, but they all supossed to point the same object.
Any advices are appreciated. Thanks
Your code is hurting by brain and I don’t have your HTML to actually test this, but If I understand your problem correctly, this should work: