Skip to content

Instantly share code, notes, and snippets.

@elmariachi111
Last active October 5, 2024 22:27
Show Gist options
  • Save elmariachi111/5407282 to your computer and use it in GitHub Desktop.
Save elmariachi111/5407282 to your computer and use it in GitHub Desktop.
JQuery-File-Upload templates written in Mustache / Handlebars
<tr class="template-download fade">
{{#error}}
<td></td>
<td class="name"><span>{{name}}</span></td>
<td class="size"><span></span></td>
<td class="error" colspan="2">
<span class="label label-important">{{error}}</span></td>
{{/error}}
{{^error}}
<td class="preview">
{{#thumbnail_url}}
<a href="{{url}}"><img src="{{thumbnail_url}}"></a>
{{/thumbnail_url}}
</td>
<td class="name">
<a href="{{url}}">{{name}}</a>
</td>
<td class="size"><span>{{fmtFileSize}}</span></td>
<td colspan="2"></td>
{{/error}}
<td>
<button class="btn btn-danger delete" data-type="{{delete_type}}" data-url="{{delete_url}}">
<i class="icon-trash icon-white"></i>
<span>Delete</span>
</button>
<input type="checkbox" name="delete" value="1" class="toggle">
</td>
</tr>
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="name">{{name}}</td>
<td class="size">{{fmtFileSize}}</td>
{{#error}}
<td class="error" colspan="2">{{error}}</td>
{{/error}}
{{^error}}
<td>
<div class="progress">
<div class="bar" style="width:0%;"></div>
</div>
</td>
<td>
<button class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Start</span>
</button>
</td>
<td>
<button class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel</span>
</button>
</td>
{{/error}}
</tr>
@abitdodgy
Copy link

Why are two templates required? What's the difference between template-upload and template-download?

@TiagoDufau
Copy link

template-upload is used before upload files.. and templete-download will replace each tr after uploads finish.

@vsalguero
Copy link

How create an trigger on additionals template elements for example

in template

in jquery
$("class").on("click",function(e){
alert("click!")
})

this code dont work

@seabamirum
Copy link

What's the best way to prevent the template-upload from displaying if there is an error with the file? Unfortunately the 'fileuploadprocessalways' callback is called after this template is rendered.

@eBaeza
Copy link

eBaeza commented Apr 22, 2016

Yes, i have the same problem as @seabamirum

@vikaschauhan1
Copy link

can anyone help me?
I have set the autoUpload to true so that I don't need to complete the upload process in two steps i.e - first select and then click on start upload.
What is happening in my case it is not displaying after selection but when I refresh the page it appears so there may be some response error in autouploading.
Please help me I am new to this.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment