SAnche
SAnche

Reputation: 1

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!

Upvotes: 0

Views: 1182

Answers (1)

Pragnesh Vaghela
Pragnesh Vaghela

Reputation: 1317

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

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

Upvotes: 1

Related Questions