我使用handlebars.js作为模板引擎,使用jQuery文件上载,当我上传一个文件时,它会在屏幕上闪烁,然后完全消失,它甚至不会隐藏在jQuery中。
我的JavaScript:
$('#photo-uploader').fileupload({
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
autoUpload: true,
maxFileSize: 5000000,
url: '/member/property/ajaxUpload',
filesContainer: $('.files'),
uploadTemplateId: null,
uploadTemplate: function(o) {
var rows = $();
$.each(o.files, function(index, file) {
var source = $('#photo-upload').html();
var template = Handlebars.compile(source);
var data = {o: o, file: file};
var template = template(data);
var row = $(template);
rows = rows.add(row);
});
return rows;
}
});车把模板:
<script id="photo-upload" type="text/x-handlebars-template">
<li class="template-upload upload-thumbs img-thumb">
<span class="preview"></span>
<a href="#" class="delete-image">Delete</a>
<a href="#" class="view-image">View</a>
<h3>Title <em>Click to edit</em></h3>
</li>
</script>如果我将uploadTemplate方法替换为示例中的方法,那么对象中唯一不同的地方就是标记。
https://github.com/blueimp/jQuery-File-Upload/wiki/Template-Engine
发布于 2013-10-23 15:14:22
将fade类添加到您的<li>中,因为jQuery文件上载使用jQuery引导来显示/隐藏元素
https://stackoverflow.com/questions/19545289
复制相似问题