jQuery File Uploader (blueimp)で問題が発生しています:
私の実装は完全にカスタマイズされています。画像のプレビューと検証を使用します。
私の問題は、fileuploadadd
イベントで data.context を定義していても、起動すると空になることfileuploadprogress
です。
$('fileinput-element').fileupload({
url: '/__module/uploadModule/receive',
type: 'post',
acceptFileTypes: acceptedFileRegEx,
dataType: 'json',
'dropZone': $(dropZone),
paramName: 'files',
autoUpload: false,
}).on('fileuploadadd', function (e, data) {
$.each(data.files, function (index, file) {
// NOTE: This function call returns a clone of an element that i use as template for upload list items. Works fine.
var component=uploadModule.getDynamicComponent('listItemContainer');
// Filling the template (code omitted due to better readabilty)
// Appending the component to my #uploadList and assigning that to data.context
data.context = component.appendTo('#uploadList');
});
// For manual submittion later on, i fill an array with the data objects from each event call
dataList.push(data);
}).on('fileuploadprocessalways', function(e,data){
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
// Further code ommitted due to readability. Here i apply file.preview and (potential) file.error to my list item that is now stored in the variable node. This works fine. My list renders perfectly well.
}).on('fileuploadprogress', function(e, data){
// PROBLEM: data.context is EMPTY ! Why???
console.log(data.context);
});
そして、これは私がアップロード開始ボタンをクリックしたときにすべてを送信する方法です:
$(dataList).each(function(){
this.submit();
});
// This works well - the uploads are being submitted and sent to the server.
私は広範なソリューションの検索、テスト、試行錯誤、デバッグを 1.5 日間行ってきました。私はこれについて頭を包むことができません。
私は何を間違っていますか?
注意:イベント コールバックdata.submit()
内で正しく実行すると、progress イベントが発生したときに正しく入力されますが、アップロード キュー全体を手動で起動するオプションはもうありません。add
data.context