Wednesday, 15 February 2012

jquery - Deferred animation in array: how to? -


I am creating a small jQuery game, where the user clicks on a single device, so many other divisions may disappear Are there.

I have yet to have a loop in the "click" event:

  function in Mediysim (IDX) {returns $ ('IMG [Data-IDEX = '' + Idx + '' ''). Fade (5000, function () {}). promise (); } $ ('.mydiv') (function () {/ * ... code fill tab result (which is an array) * / var tabFadingOut = []; for (var i = 0; i & lt ; TabResult.length; I ++) {tabFadingOut.push (makeDisappear (tabResult [i]))}} $ .apple ($, tabfadingout) .done (function () {console.log ('Done'); }}}  

If you read the code, then I promise () the objects and put them in tabResult (which is an array), then I send this array When I try () and it does not work for me to appear in the console log How to fix any idea?

Your code works fine for me Please see the working Bela:

  $ (function () {function macDypecer (idx) {returns $ ('divi [data-idex =' '+ idx +'] ']' ). Click Fade (5000, function () {}) $ ('.mydiv') {var tabResult = [1, 2, 3]; var tabFadingOut = []; (var i = 0 ; I & lt; tabResult.length; I ++) {tabFadingOut.push (MacDiPier (TabRsult [I])) $ $ when. Apely ($, tabfadingout) .done (function () {console.log ('full');});});});  

Bella working here:


No comments:

Post a Comment