Animation callback with parameters generated by a for loop

Animation callback with parameters generated by a for loop

Hi,

First post for me!! .. I'm stuck in a big problem whose solution is quite urgent. Please help me.

Why the following doesn't work??? It alert n times (with n=arrIDPortletNavigationDependent.length) the same element of the array: the last one.

how to fix it?

function FadeOutAnyPortletAndAFTERalertTheirID()
{

   for (i=0; i<arrIDPortletNavigationDependent.length; i++ )  //arrIDPortletNavigationDependent exists and contain 4 items
   {   
      istruzione='alert('+arrIDPortletNavigationDependent[i]+')'

      jQuery("#pt-portlet-content-"+arrIDPortletNavigationDependent[i]).stop(true, false)
      jQuery("#pt-portlet-content-"+arrIDPortletNavigationDependent[i]).animate({opacity: 0.0}, 1000, "swing", function () {eval(istruzione)})      
   }

}


Thanks.
Bye.