how can I reset a blueimp jQuery fileupload plugin?
here is an ideal solution to reset jquery-fileupload
in the file "main.js" just delete or comment Load existing file script like this:
if (window.location.hostname === 'blueimp.github.io') {
// Demo settings:
$ ('# fileupload'). fileupload ('option', {
url: '//jquery-file-upload.appspot.com/',
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test (window.navigator.userAgent)
maxFileSize: 999000,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
});
// Upload server status check for browsers with CORS support:
if ($ .support.cors) {
$ .Ajax ({
url: '//jquery-file-upload.appspot.com/',
type: 'HEAD'
}). fail (function () {
$ ('<div class = "alert alert-danger" />')
.text ('Upload server currently unavailable -' +
new Date ())
.appendTo ( '# fileupload');
});
}
} else {
// Load existing files:
/ * $ ('# fileupload'). addClass ('fileupload-processing');
$ .Ajax ({
// Uncomment the following to send cross-domain cookies:
// xhrFields: {withCredentials: true},
url: $ ('# fileupload'). fileupload ('option', 'url')
dataType: 'json',
context: $ ('# fileupload') [0]
}). always (function () {
$ (This) .removeClass ( 'fileupload-processing');
}). done (function (result) {
$ (this) .fileupload ('option', 'done')
.call (this, $ .Event ('done'), {result: result});
});
* /}
so you have to either clear or comment on the part "// Load existing files"
The answer to this was a lot simpler than I expected:
$("table tbody.files").empty();
Previously, I think I was doing too much -- attempting to destroy/reset the container didn't work as well.
With this one line of code, the lists appear to reset and all is working well as far as I can tell.