0

I'm trying to use this in coffeescript :

  $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn 1000, arguments.callee
  $(this).promise().done -> console.log 'hey trip'

The same thing in au naturale JS

  $(this).hide().each(function(index) {
    $(this).delay(index * 100).fadeIn(1000, arguments.callee)
  });
  $(this).promise().done(function() {console.log 'hey trip' });

And I'd like to execute the console log once the animation is complete. But this snippet here never delivers the console message ( in general ), let alone when the animation completes.

Anyone know how to use the promise objects appropriately?

Second Failing Attempt :

  promise = new $.Deferred ->
  promise.done -> console.log 'hey trip'

  promise.resolve( $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn 3000, arguments.callee
  )

Third failing Variation

dfd = $.Deferred ->
dfd.done(
  $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn(3000, arguments.callee)
).done -> console.log 'hey trip'

Fourth failing variation

$.when(
  $(this).hide().each (index) ->
    $(this).delay(index * 100).fadeIn(3000, arguments.callee)
).then -> console.log 'hey trip' 
Trip
  • 26,756
  • 46
  • 158
  • 277

1 Answers1

2

It's your arguments.callee parameter to .fadeIn().

If you take that out, it works... See http://jsfiddle.net/alnitak/9VQ48/

Alnitak
  • 334,560
  • 70
  • 407
  • 495
  • That works! How does arguments.callee cancel that out!? Wow thanks so much for that Alnitak. I owe you one. – Trip Jul 22 '12 at 21:08
  • @Trip I haven't figured that out yet. Maybe you can't mix completion callbacks with promises? In any event, `.callee` doesn't seem to make sense in that context? – Alnitak Jul 22 '12 at 21:10
  • I had never known. Thanks again :D – Trip Jul 22 '12 at 21:13