Rails的'.js.erb'不呈现部分 [英] Rails '.js.erb' not rendering partial

查看:91
本文介绍了Rails的'.js.erb'不呈现部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用Rails 3.2.13,而我想做的是呈现部分内容,然后使用jquery将其附加到div:

So, i'm working with rails 3.2.13 and what i'm trying to do is render a partial and then append it to a div using jquery:

$("#notifications").append("<%=raw escape_javascript(render('layouts/notification')) %>");

它现在做什么,是将其追加到正确的div上,但不呈现部分或任何内容,它仅将rails代码呈现为字符串..我不知道我在做什么错但我敢打赌,我想念的东西很愚蠢.

what it does right now, is it appends it to the right div but it doesn't render the partial or anything, it just renders the rails code as a string.. I don't know what i'm doing wrong but i bet its something silly that i'm missing.

感谢您的任何帮助

推荐答案

尝试render_to_string而不只是render

这篇关于Rails的'.js.erb'不呈现部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆