开发者

How to render view template by jQuery in Rails

开发者 https://www.devze.com 2023-01-05 01:44 出处:网络
I need to render view template by jQuery. I have template \'category.html.erb\' and file \'category.js.erb\' with following code:

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

精彩评论

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