После загрузки нескольких файлов шаблон загрузки не загружается - PullRequest
0 голосов
/ 24 сентября 2018

Когда я загружаю несколько файлов с параметром 'SingleFileUpload', установленным в значение false, шаблон загрузки не заменяется шаблоном загрузки для нескольких файлов, хотя я получаю от сервера успешный ответ на файл.Но класс 'template-upload fade in' изменился на 'template-upload fade in', который скрыт.Пожалуйста, найдите скриншот прилагается.Когда сервер работает очень медленно, шаблон загрузки заменяется шаблоном загрузки для всех файлов.Но, когда сервер работает нормально или быстро, эта проблема возникает. Снимок экрана загруженного файла

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

    });

Я обнаружил, что проблема заключается в jquery.fileupload-ui.js в строке обратного вызова «done» № 188. Строки, выделенные жирным шрифтом, используются для визуализациискачать шаблон.Но в моем случае эти строки не являются триггерными, поэтому шаблон загрузки не отображается.Я не знаю, как решить эту проблему, так как они использовали $ .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;
        },
...