2013-02-20 107 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()) 
相关问题