上载多个文件后,无法获取下载模板

时间:2018-09-24 07:50:39

标签: jquery file jquery-file-upload blueimp

当我将“ SingleFileUpload”设置为false的多个文件上载时,即使我从服务器收到文件的成功响应,上载模板也不会被少数文件的下载模板所取代。但是,“模板上传淡入”类已更改为“模板上传淡入”。请找到所附的屏幕截图。当服务器非常慢时,所有文件的上传模板都将替换为下载模板。但是,当服务器正常或快速运行时,就会发生此问题。 Uploaded File Screenshot

 $('#fileupload').fileupload({
        url: 'xxxx',
        method: "POST",
        autoUpload: true,
        singleFileUploads: false,
        sequentialUploads: false,
        limitMultiFileUploads: 2

    });

我发现问题出在'done'回调行188的jquery.fileupload-ui.js中。加粗的行用于呈现下载模板。但是在我的情况下,这些行不会触发,因此不会呈现下载模板。我不知道如何解决此问题,因为他们使用了$ .Deffered()。任何人都可以帮助工作。

 done: function (e, data) {
                    if (e.isDefaultPrevented()) {
                        return false;
                    }
                    var that = $(this).data('blueimp-fileupload') ||
                            $(this).data('fileupload'),
                        getFilesFromResponse = data.getFilesFromResponse ||
                            that.options.getFilesFromResponse,
                        files = getFilesFromResponse(data),
                        template,
                        deferred;

                    if (data.context) {
                        data.context.each(function (index) {
                            var file = files[index] ||
                                    { error: 'Empty file upload result' };
                            deferred = that._addFinishedDeferreds();
                             that._transition($(this)).done(
                                **function () {
                                    var node = $(this);
                                    template = that._renderDownload([file])
                                        .replaceAll(node);
                                    that._forceReflow(template);
                                    that._transition(template).done(
                                        function () {
                                            data.context = $(this);
                                            that._trigger('completed', e, data);
                                            that._trigger('finished', e, data);
                                            deferred.resolve();
                                        }
                                    );
                                }**
                            );
                        });
                    } else {
                        template = that._renderDownload(files)[
                            that.options.prependFiles ? 'prependTo' : 'appendTo'
                        ](that.options.filesContainer);
                        that._forceReflow(template);
                        deferred = that._addFinishedDeferreds();
                        console.log('Not context Download');
                        that._transition(template).done(
                            function () {
                                data.context = $(this);
                                that._trigger('completed', e, data);
                                that._trigger('finished', e, data);
                                deferred.resolve();
                            }
                        );
                    }
                },
 _transition: function (node) {
            var dfd = $.Deferred();
            if ($.support.transition && node.hasClass('fade') && node.is(':visible')) {
                 node.on(
                    $.support.transition.end,
                    function (e) {
                        // Make sure we don't respond to other transitions events
                        // in the container element, e.g. from button elements:
                        if (e.target === node[0]) {
                            node.unbind($.support.transition.end);
                            dfd.resolveWith(node);
                        }
                    }
                ).toggleClass('in');
            } else {
                node.toggleClass('in');
                dfd.resolveWith(node);
            }
            return dfd;
        },

0 个答案:

没有答案