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')) %>");
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.
Any help would be appreciated thanks
尝试render_to_string
而不只是render
尝试这个:
$("#notifications").append("<%= escape_javascript(render(:partial => 'layouts/notification')) %>");
if its a regular partial (under the same view) then:-
$("#notifications").append("<%= escape_javascript(render(:partial => 'notification')) %>");
else
$("#notifications").append("<%= escape_javascript(render(:partial => 'layouts/notification')) %>");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.