我想在的CoffeeScript使用:不适当地使用jQuery promise对象。不知道为什么
$(this).hide().each (index) ->
$(this).delay(index * 100).fadeIn 1000, arguments.callee
$(this).promise().done -> console.log 'hey trip'
同样的事情在太子港博纳自然JS
$(this).hide().each(function(index) {
$(this).delay(index * 100).fadeIn(1000, arguments.callee)
});
$(this).promise().done(function() {console.log 'hey trip' });
而且我想执行的控制台日志一旦动画完成。但是这段代码从来没有提供控制台消息(通常),更不用说当动画完成时。
任何人都知道如何正确使用promise对象?
其次失败尝试:
promise = new $.Deferred ->
promise.done -> console.log 'hey trip'
promise.resolve($(this).hide().each (index) ->
$(this).delay(index * 100).fadeIn 3000, arguments.callee
)
三没有变化
dfd = $.Deferred ->
dfd.done(
$(this).hide().each (index) ->
$(this).delay(index * 100).fadeIn(3000, arguments.callee)
).done -> console.log 'hey trip'
四没有变化
$.when(
$(this).hide().each (index) ->
$(this).delay(index * 100).fadeIn(3000, arguments.callee)
).then -> console.log 'hey trip'
这是CoffeeScript的? – Alnitak 2012-07-22 20:17:45
是的,非常抱歉。我更新了我的答案。 – Trip 2012-07-22 20:18:20
这与活动委派没有关系...... – 2012-07-22 20:18:43