Scusate la lunga assenza prima della risposta. Il mio problema l'ho risolto, esattamente in questo modo:
codice:$.each( data, function(id,file) { $("#maincontent").html(""); var fileDetails = $("<p>").html("<b>Nome file:</b> " + "<a href='#commentTextID'>" + file.original_name + "</a><b> Consegnato il: </b>" + file.uploaded_at + "<b> Commento: </b>" + file.comment).attr("data-id", id).attr("data-hash", file["hash"]); fileDetails.click(function(){ $("#fileNameComment").html(""); var details = $(this); idFileToComment = details.attr("data-id"); hashFileToComment = details.attr("data-hash"); $("#fileNameComment").append("Add comment for " + file.original_name); console.log(details.attr("data-hash")); }); $("#filesField").append(fileDetails); }); }else{ alert("Nothing uploaded for this assignment."); }

Rispondi quotando