2
我正在使用jQuery File upload plugin。在單個頁面上有多個文件上傳器的實例。
看看這裏的一個例子在jsFiddle
$(function() {
$('.file_upload').fileUploadUI({
uploadTable: $('#files'),
downloadTable: $('#files'),
buildUploadRow: function (files, index) {
// HOW TO DETERMINE WHICH FILE_UPLOADER Was Clicked?
// Need a reference point so I can find the right, #files1 or #files2
return $('<tr><td>' + files[index].name + '<\/td>' +
'<td class="file_upload_progress"><div><\/div><\/td>' +
'<td class="file_upload_cancel">' +
'<button class="ui-state-default ui-corner-all" title="Cancel">' +
'<span class="ui-icon ui-icon-cancel">Cancel<\/span>' +
'<\/button><\/td><\/tr>');
},
buildDownloadRow: function (file) {
return $('<tr><td>' + file.name + '<\/td><\/tr>');
}
});
});
我遇到的問題是,當用戶單擊上傳文件,我不知道他們點擊其中之一。我需要知道他們點擊了哪一個,因爲我想要插件的buildUploadRow等。知道在哪裏構建行。我嘗試使用$(this),但沒有得到選擇器,表單元素,這是我所需要的。