blueimp / jQuery-File-Upload

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.
https://blueimp.github.io/jQuery-File-Upload/
MIT License
30.95k stars 7.95k forks source link

Progress bar doesn't fadeOut after modifying 'stop' callback #2907

Closed sgiraldo closed 10 years ago

sgiraldo commented 10 years ago

Hi,

In order to launch an own application after a file is uploaded, I have updated the 'stop' callback on jquery.fileupload-ui.js. Here you have the content

stop: function (e) { if (e.isDefaultPrevented()) { return false; } var that = $(this).data('blueimp-fileupload') || $(this).data('fileupload'), deferred = that._addFinishedDeferreds(); $.when.apply($, that._getFinishedDeferreds()) .done(function () { that._trigger('stopped', e); }); that._transition($(this).find('.fileupload-progress')).done( function () { $(this).find('.progress') .attr('aria-valuenow', '0') .children().first().css('width', '0%'); $(this).find('.progress-extended').html(' '); deferred.resolve(); } ); showPhotos(); }

The function is called perfectly, but the progress bar doesn't fadeOut, even having reached 100%. I've tried putting the call to "loadPhotos" in 'processstop' or 'done' callback, but the result is the same.

I don't know if I'm completely wrong editing this piece of script. Are there another easy way to call my own function without modifying the usual flow of the script? Can I force the fadeOut of the progressbar before calling my own function??

Thanks.

EndyKaufman commented 10 years ago
function init_fileupload()
{
    uploadButton = $('
input type="file" class="form-control asfileupload " data-action="http://upload.url" data-progress-selector="#progress-image .progress-bar" data-fileslist-selector="#fileslist-image" id="image" name="image" placeholder=""
blueimp commented 10 years ago

If you override functionality, you'll need to reimplement that functionality. To listen to the stop event without overriding the UI version stop callback, please use the fileuploadstop event: https://github.com/blueimp/jQuery-File-Upload/wiki/Options#wiki-callback-options