# Render action inside js template

**URL:** <https://www.ruby-forum.com/t/render-action-inside-js-template/174552>\
**Category:** Rails\
**Created:** [August 28, 2009, 3:28pm UTC](https://www.ruby-forum.com/t/render-action-inside-js-template/174552 "2009-08-28T15:28:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabiokr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/cdc98d/32.png) [@fabiokr](https://www.ruby-forum.com/u/fabiokr)\
**Post date:** [August 28, 2009, 3:28pm UTC](https://www.ruby-forum.com/t/render-action-inside-js-template/174552/1 "2009-08-28T15:28:53Z")

</div>

Hello all,

I’m trying to create the following:

There is a index page that lists some items, and ‘new item’ button. I  
want the user to be able to click the button, and with ajax the page  
will be refreshed to show the new item form.

For that, I added a format.js on my controller, and created a  
new.js.erb file for the action.

My problem is, how can I, inside the new.js template, print the  
new.html action?

Something like this:  
$("#inner-content").html("\<%= escape\_javascript(render(:action =\>  
‘new’)) %\>");

It doesn’t work. Do I really have to create a partial for the entire  
form to accomplish this?

Thank you!

---

<div class="post-metadata">

**Author:** ![fabiokr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/cdc98d/32.png) [@fabiokr](https://www.ruby-forum.com/u/fabiokr)\
**Post date:** [August 31, 2009, 12:43pm UTC](https://www.ruby-forum.com/t/render-action-inside-js-template/174552/2 "2009-08-31T12:43:13Z")

</div>

Any thoughts?
