开发者

How to render view template by jQuery in Rails

I need to render view template by jQuery. I have template 'category.html.erb' and file 'category.js.erb' with following code:

    $("#block").html("<%= escape_javascript(render :template => 'category') %>");

but it doesn't render 开发者_如何学编程category view template.

Please help me!


Try $("#block").html("<%= escape_javascript(render(:template => 'category')) %>");

I prefer rendering a partial like: $("#block").html("<%= escape_javascript(render(:partial => 'category')) %>");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜