DropZone Help:
Step-1.
<form action="/projects/<%=current_ project.try(:id)%>/uploads/ dropzone_file_upload? recommendation_id=<%=recommend ation.id%>" class="dropzone" id="demo-upload-<%=recommendat ion.id%>">
<div class="dz-message needsclick">
Drop files here or click to upload.<br />
</div>
</form>
<div id="preview-template" style="display: none;">
<div class="dz-preview dz-file-preview">
<div class="dz-image"><img data-dz-thumbnail /></div>
<div class="dz-details">
<div class="dz-size"><span data-dz-size></span></div>
<div class="dz-filename"><span data-dz-name></span></div>
</div>
<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span> </div>
<div class="dz-error-message"><span data-dz-errormessage></span></ div>
</div>
</div>
<script>
dropzonSet("<%=recommendation. id%>");
</script>
Step-1.
<form action="/projects/<%=current_
<div class="dz-message needsclick">
Drop files here or click to upload.<br />
</div>
</form>
<div id="preview-template" style="display: none;">
<div class="dz-preview dz-file-preview">
<div class="dz-image"><img data-dz-thumbnail /></div>
<div class="dz-details">
<div class="dz-size"><span data-dz-size></span></div>
<div class="dz-filename"><span data-dz-name></span></div>
</div>
<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span>
<div class="dz-error-message"><span data-dz-errormessage></span></
</div>
</div>
<script>
dropzonSet("<%=recommendation.
</script>
Step-2.
var dropzonSet = function(recommendation_id){
docsDropzone = new Dropzone( "#demo-upload-"+ recommendation_id, {
init: function() {
this.on("complete", function (file) {
data = JSON.parse(file.xhr.response)
files=data.attachments>1 ? "Files" : "File"
$("#attached_file_"+data. recommendation).html(data. attachments + " "+ files +" attached")
html_remove_image = "<a href='#' data-href='/uploads/dropzone_ file_destroy?upload_id="+data. file+"&recommendation_id="+ data.recommendation+"' class='remove-image remove-link-image' data-id='"+data.file+"'>X</a>"
$(file.previewElement). prepend(html_remove_image)
total_attachments = $($(".remove-image.remove- link-image").map(function(){ return $(this).data("id")}).get()). size()
file_count = total_attachments > 1 ? "Files" : "File"
$("#img-attached_file").html( total_attachments + " " + file_count + " Attached");
});
}
} );
}
docsDropzone = new Dropzone( "#demo-upload-"+
init: function() {
this.on("complete", function (file) {
data = JSON.parse(file.xhr.response)
files=data.attachments>1 ? "Files" : "File"
$("#attached_file_"+data.
html_remove_image = "<a href='#' data-href='/uploads/dropzone_
$(file.previewElement).
total_attachments = $($(".remove-image.remove-
file_count = total_attachments > 1 ? "Files" : "File"
$("#img-attached_file").html(
});
}
} );
}
Step-3.
respond_to do |format|
format.json do
render :json => {file: @file.id, recommendation: @recommendation.try(:id), attachments: @recommendation.try(:uploads). try(:size)}
end
end
format.json do
render :json => {file: @file.id, recommendation: @recommendation.try(:id), attachments: @recommendation.try(:uploads).
end
end
No comments:
Post a Comment