I have a weird problem with jQuery File Upload plugin. If I use this sitax:
$('fileupload').fileupload({
url: myurl,
add: function(e, data){
console.log("add event");
},
processalways: function(e, data){
console.log("processalways event");
}
});
processalways event don't occur, but I got correct data.context variable (i.e. the div with the progress bar of the added file).
While when I use this sintax
$('fileupload').fileupload({
url: myurl
}).on('fileuploadadd',function(e, data){
console.log("add event");
}).on('fileuploadprocessalways', function(e, data){
console.log("processalways event");
});
processalways event correctly occur, but I got wrong data.context (I think in this case data.context will always refer to $('fileupload') element.
I need both process event and data.context variable. How can I do?
I had read a bit code in jquery.fileupload-ui.js
Maybe this is what you want?
First syntax
If you want to start the process you have to call
data.submit();
into the add fnction.Then you can't call a
processalways
callback, according to the documentation it'salways
which should be used :Second syntax
I've never use it, but if it works it's because
fileuploadd
doesn't exist. And so it's the defaultfileuploadadd
which is used, and it may calldata.submit()
.