jQuery Ajax File Uploader Widget multi image preview is inverted, last image is first, and first image is last

116 views Asked by At

I use the following jQuery Ajax File Uploader Widget: https://github.com/danielm/uploader As you can see in the demo, the order of previewing the images is reversed.

Demo URL: https://danielmg.org/demo/java-script/uploader/basic

I want to fix this and i don't know how. I don't have very good knowledge of javascript. If anyone is good at Javascript and wants to help me with this issue, I would be grateful.

Thank you! Regards

1

There are 1 answers

2
Claudiu On

I found the solution, in the javascript file ui.js was the following function:

// 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);
}

I changed prepend(template) with append(template), and now the uploading filles will show in the correct format.

Thanks anyway, I hope it is useful to other users.