2012-03-01 96 views
2

所有, 我试图使用jQuery的文件上传演示: http://blueimp.github.com/jQuery-File-Upload/的Javascript模板引擎使用jQuery的

我的问题是,它在它使用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.fileupload得到一些错误在这些线路上-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博客时,它总是失败,我不认为我复制的唯一东西是package.JSON和初始下载中的.gitignore文件。这些文件有什么意义?试图了解这个模板是什么以及如何使用它?

任何事情你可以提前指示我非常感谢!谢谢您的帮助!

回答

1

.gitignore是源代码管理文件,与脚本无关 - 请参阅http://help.github.com/ignore-files/了解更多信息。

package.JSON是jquery插件的元数据文件,供新的jquery插件站点使用,与您试图使用的插件的功能无关 - 请参阅https://github.com/jquery/plugins.jquery.com#readme以获取更多信息。

我最好的猜测是这个错误是插件和你在wordpress上已经有的脚本文件的冲突。

你能发布实际的错误信息吗?