I'm experimenting with Blueimp's jQuery-File-Upload plugin, which judging by the demo looks very promising.
It's really easy to implement:
var $uploadButton = $("#fileop-upload");// <input type="file" id="fileop-upload" [etc] />
$uploadButton.fileupload({
url : "//domain/path/to/receive-uploaded-files"
});
The selected files are uploaded fine without refreshing the page as expected, but of course with a minimal configuration like this the user won't get any notification. Here's where the plugin's callbacks would come in handy.
According to the documentation there are two ways to define callbacks. For example the add
event (which fires whenever a file is selected for uploading) can be added in the original configuration object like this:
$uploadButton.fileupload({
add : addFileListener,
url : "//domain/path/to/receive-uploaded-files"
});
or alternatively:
$uploadButton.bind("fileuploadadd", addFileListener);
However I've found that only the first approach works, the second one doesn't do anything.
It is even more curious that no other callbacks -- especially progress
and start
-- seems to be firing not matter how I bind them:
$uploadButton.fileupload({
add : addFileListener,
progress : progressListener,
start : startListener,
url : "//domain/path/to/receive-uploaded-files"
});
or
$uploadButton.fileupload({
add : addFileListener,
url : "//domain/path/to/receive-uploaded-files"
});
$uploadButton.bind("fileuploadprogress", progressListener");
$uploadButton.bind("fileuploadstart", startListener");
I have the referred listener functions defined, and the code doesn't report any errors or warnings.
What is the explanation for the .bind
method's failure, and why doesn't the progress
or the start
listeners ever activate?