【发布时间】:2013-09-30 07:04:16
【问题描述】:
我正在尝试调用file uploader 插件。选择文件时,将从库中调用add 方法。在调用add 时,我需要以add 方法作为参数传递父方法参数opts。
这是一段使用 RequireJS 库的代码。
return {
onFileChoose: function (e, data) {
// I need 'opts' object here
},
start: function (opts) {
$('fileupload').fileupload({
url: '//testbucket.s3.amazonaws.com', // Grabs form's action src
type: 'POST',
autoUpload: true,
dataType: 'xml',
add: this.onFileChoose
});
}
}
我需要onFileChoose 中的opts 对象。
我试过了
add: function (e, data) {
this.onFileChoose(e, data, opts);
}
上面的代码产生了this.onFileChoose is undefined的错误。
如何解决这个问题?
【问题讨论】:
标签: javascript jquery scope this jquery-file-upload