2012-03-01 84 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上已經有的腳本文件的衝突。

你能發佈實際的錯誤信息嗎?