2013-02-20 106 views
4

我有一個問題,我的Rails應用程序3:我在我看來,以顯示上傳進度條已經腳本(上傳過程的工作):[滑軌] jQuery的:語法錯誤,無法識別的表達

<h1>Ajouter des images:</h1> 

<%= form_for [:admin, :gallery, @painting], html: { multipart: true} do |f| %> 

    <%= f.hidden_field :gallery_id %> 

    <%= f.label :image, "Upload paintings:" %> 

    <%= f.file_field :image, multiple: true, name: "painting[image]" %> 

<% end %> 

<script id="template-upload" type="text/x-tmpl"> 
    <div class="upload"> 
    {%=o.name%} 
    <div class="progress"><div class="bar" style="width: 0%"></div></div> 
    </div> 
</script> 

但是,當我嘗試上傳文件,我得到這個錯誤:

Uncaught Error: Syntax error, unrecognized expression: <div class="upload"> 
    Argentina.gif 
    <div class="progress"><div class="bar" style="width: 0%"></div></div> 
</div> 

即將形式的jquery.js文件:

Sizzle.error = function(msg) { 
    throw new Error("Syntax error, unrecognized expression: " + msg); 

我REA我不知道如何解決它,我已經尋求很多! 感謝您的幫助!

+0

那麼,是jQuery的在你的代碼? – undefined 2013-02-20 17:26:59

+0

在rails上的ruby中,jquery lib包含在「寶石」中,所以我沒有直接訪問該文件。感謝您的回答 ! – khcr 2013-02-20 17:34:01

+0

沒有解決方案?我得到與其他HTML標籤完全相同的錯誤! – khcr 2013-02-21 15:35:00

回答

0

jquery-file-upload在ruby 1.9.x中存在兼容性問題。最近有修復https://github.com/blueimp/jQuery-File-Upload/pull/2031

其他人有同樣的問題(包括我自己)https://github.com/waynehoover/s3_direct_upload/issues/47

嘗試使用bundle update jquery-fileupload-rails更新您的寶石。 (我假設你使用那個寶石。)

+0

謝謝你的解決方案! – khcr 2013-02-24 00:09:38

+0

添加裝飾使其兼容 – Uchenna 2013-06-01 15:56:48

0

刪除jquery函數$()當你使用模板。這與Jquery 1.9.1兼容。你應該處理模板像波紋管

tmpl("template-upload", {file: file, icon: icon_name[type]}) 

,而不是

$(tmpl("template-upload", {file: file, icon: icon_name[type]})) 
0

使用最新版本的jQuery,添加tril它應該做的伎倆

$(tmpl("template-upload", {file: file, icon: icon_name[type]}).trim()) 
相關問題