Javascript模板引擎与jQuery一起使用
Javascript Template Engine Use with jQuery
全部,我正在尝试使用jQuery文件上传演示:http://blueimp.github.com/jQuery-File-Upload/
我的问题是它在文档中说它使用Javascript模板引擎(https://github.com/blueimp/jQuery-File-Upload/wiki/Template-Engine)
然而,我对这个过程并不熟悉。我正在尝试将其集成到我的Wordpress博客中,以允许以这种方式上传文件。在index.html中,它定义了以下模板:
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="name">{%=file.name%}</td>
<td class="size">{%=o.formatFileSize(file.size)%}</td>
{% if (file.error) { %}
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else if (o.files.valid && !i) { %}
<td>
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="start">{% if (!o.options.autoUpload) { %}
<button class="btn btn-primary">
<i class="icon-upload icon-white"></i> {%=locale.fileupload.start%}
</button>
{% } %}</td>
{% } else { %}
<td colspan="2"></td>
{% } %}
<td class="cancel">{% if (!i) { %}
<button class="btn btn-warning">
<i class="icon-ban-circle icon-white"></i> {%=locale.fileupload.cancel%}
</button>
{% } %}</td>
</tr>
{% } %}
</script>
我使用的是jQuery Tmpl代码(https://github.com/jquery/jquery-tmpl)当我尝试在Wordpress博客中创建这个时,我在jquery.filelpload-ui.js文件中的以下几行出现了一些错误:
_initTemplates: function () {
var options = this.options;
options.templateContainer = document.createElement(
this._files.prop('nodeName')
);
options.uploadTemplate = tmpl(options.uploadTemplateId);
options.downloadTemplate = tmpl(options.downloadTemplateId);
},
在该文件的早期,它被定义为:uploadTemplateId:"模板上传",
我很困惑为什么这不起作用,甚至不知道如何使用我自己的javascript模板来做到这一点?当我试图将这些文件复制到Wordpress博客中时,它总是失败,我认为我唯一没有复制的就是包。JSON和初始下载中的.gitignore文件。这些文件有什么意义?只是想了解这个模板是什么以及如何使用它?
如果你能提前给我指给我,我将不胜感激!谢谢你的帮助!
.gitignore
是一个源代码管理文件,与脚本无关-请参阅http://help.github.com/ignore-files/了解更多信息。
package.JSON
是jquery插件的元数据文件,供新的jquery插件网站使用,与您尝试使用的插件的功能无关-请参阅https://github.com/jquery/plugins.jquery.com#readme了解更多信息。
我对这个错误的最佳猜测是插件和wordpress上已有的脚本文件之间的冲突。
你能发布实际的错误消息吗?
- 将jQuery UI Timepicker Addon与React一起使用
- 将FormParams与Jersey和jQuery一起使用
- 将Jquery与wordpress主题一起使用
- 存储数据的最佳方式是什么,以便与jquery一起使用
- 将jQuery.css()与变量一起使用
- 如何将jquery ui与requirejs一起使用
- 注入的元素和jQuery脚本.如何让他们一起工作
- 有条件地创建ajax url参数以与jQuery Validate一起使用
- 在使用 Django 静态文件时动态设置映像时,只有绝对路径才能与 jquery 一起使用
- 使一组对象与 jQuery 一起拖动
- 将 jQuery UI 日期选择器与异步 AJAX 请求一起使用
- 通过 jQuery Find and Replace 将文本 URL 与 标记包装在一起
- 将jQuery动画与angular的ngAnimate一起使用
- 将 jQuery trigger() 与 hoverIntent 一起使用
- Jquery 工具提示未随 AJAX 数据加载一起显示
- Jquery animate 不能与 IE 一起使用 - 什么也没发生
- jQuery脚本不想一起工作
- While循环与jquery中的某些数学函数一起崩溃
- 合并多个画布在一个单一的DIV一起- JQuery
- 如何让两个框架拖在一起?(jQuery)