【问题标题】:jQuery Ajax File Uploader Widget multi image preview is inverted, last image is first, and first image is lastjQuery Ajax File Uploader Widget多图预览倒置,最后一张图片在前,第一张图片在最后
【发布时间】:2022-01-05 04:55:54
【问题描述】:

我使用以下 jQuery Ajax 文件上传器小部件:https://github.com/danielm/uploader 正如您在演示中看到的那样,预览图像的顺序是相反的。

演示网址:https://danielmg.org/demo/java-script/uploader/basic

我想解决这个问题,但我不知道如何解决。我对javascript没有很好的了解。如果有人擅长 Javascript 并想帮助我解决这个问题,我将不胜感激。

谢谢! 问候

【问题讨论】:

    标签: javascript image file uploader


    【解决方案1】:

    我找到了解决方案,在 javascript 文件 ui.js 中有以下函数:

    // Creates a new file and add it to our list
    function ui_multi_add_file(id, file, file_type) {
    var template = $('#files-template-' + file_type).text();
    template = template.replace('%%filename%%', file.name);
    
    template = $(template);
    template.prop('id', 'uploaderFile' + id);
    template.data('file-id', id);
    
    $('#files-' + file_type).find('li.empty').fadeOut(); // remove the 'no files yet'
    $('#files-' + file_type).prepend(template);
    }
    

    我将 prepend(template) 更改为 append(template),现在上传的填充将以正确的格式显示。

    还是谢谢了,希望对其他用户有用。

    【讨论】:

    • 如果您回答了自己的问题,请随时接受它作为答案,以便其他人知道它解决了问题。
    • 好的,我就这样做,因为目前他不允许我直到两天后。
    猜你喜欢
    • 1970-01-01
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-15
    • 2012-02-10
    相关资源
    最近更新 更多