I am using jQuery 2.0 with html5Uploader plugin to upload files via ajax, and I have following problem (stick on this one with me). Every time when file is being uploaded, this element is being appended to the upload box:
var fileTemplate = "<div ole=\"id_image\" id=\"{{id}}\" class=\"clearfix fl slika_prv\" >";
fileTemplate += "<div class=\"preview\"></div>";
fileTemplate += "<div class=\"filename\">{{filename}}</div>";
fileTemplate += "<a href=\"" + url_tmp_delete + "\" class=\"image_delete_tmp\">Obriši Sliku</a>";
fileTemplate += "</div>";
And when the upload is successful, this function is being called:
onSuccess : function(e, file, data) {
$('.image_delete_tmp').attr('data-id', data);
var img_delete = $('.image_delete_tmp');
delete_image(img_delete, 'tmp');
}
It adds id data to the a tag. This a tag is for deleting the uploaded file, and data is name of the file being uploaded (response from the server). My problem is how to add unique id to image that is being uploaded (at the moment all a tag have same id (of the last uploaded file))? I know that this is confusing question, but at the moment this is best I can do :(.