【发布时间】:2012-12-24 21:20:02
【问题描述】:
我试图从回调中获取返回 this,但我总是未定义。
这里是截图
create: function(currentView, data){
var itsMe = this;
this.thumbsWrapper = this.templates.wrapper().hide();
currentView.append(this.thumbsWrapper);
this.thumbsWrapper.fadeIn("fast", function(){
return itsMe;
});
},
var l = list().create(currentView); //need teh return that i can use chaining
var l 现在是未定义的,如果我使用带有回调的fadeIn... 如果我不在回调中使用fadeIn,它会返回obj
有人知道为什么吗?
【问题讨论】:
-
因为回调将值返回到它被调用的位置,即
.fadeIn内部的某个位置。对create函数没有影响。
标签: javascript callback return chaining