【发布时间】:2018-03-01 22:48:24
【问题描述】:
我尝试在执行函数后将数据上下文传递给延迟对象以修改数据:
function confirmBox(obj){
var defer = $.Deferred();
//cut the function
//if true, it will returned the obj, by false it will be defer.reject()
defer.resolve(obj);
return defer.promise();
}
$.link.testTemplate("#main", app)
.on("click", ".test-item", function(e){
confirmBox($.view(this)).then(function (answer) {
console.log(answer.getIndex())
});
//console.log($.view(this).getIndex()) => working fine
})
它返回了一个未定义的值。
我的错误在哪里?
【问题讨论】: