# Generating a form using form\_tag/remote\_form\_tag in an RJS template?

**URL:** <https://www.ruby-forum.com/t/generating-a-form-using-form-tag-remote-form-tag-in-an-rjs-template/123852>\
**Category:** Rails\
**Created:** [December 21, 2007, 10:26am UTC](https://www.ruby-forum.com/t/generating-a-form-using-form-tag-remote-form-tag-in-an-rjs-template/123852 "2007-12-21T10:26:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [December 21, 2007, 10:26am UTC](https://www.ruby-forum.com/t/generating-a-form-using-form-tag-remote-form-tag-in-an-rjs-template/123852/1 "2007-12-21T10:26:09Z")

</div>

Is there a way to use the form\_tag/remote\_form\_tag helpers in an RJS  
template? I want to replace the innerHTML of a div with a remote form  
as the result of an AJAX request and I’m not having any luck getting  
it to work. I’m trying something like this:

page.replace\_html “delete\_div”, form\_tag(:url=\>"/listings") do  
submit\_tag “Delete” end

but that doesn’t work very well. The element is generated but  
the block seems to be ignored. I’ve tried a million other variations  
and can’t get them to work either. Any way to use these helpers in an  
RJS template? If not, how else can I do what I’m trying to do?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [December 21, 2007, 10:51am UTC](https://www.ruby-forum.com/t/generating-a-form-using-form-tag-remote-form-tag-in-an-rjs-template/123852/2 "2007-12-21T10:51:47Z")

</div>

put the stuff in a partial and render that:

page.replace\_html “delete\_div”, :partial =\> “my\_form”

---

<div class="post-metadata">

**Author:** ![acampos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@acampos](https://www.ruby-forum.com/u/acampos)\
**Post date:** [December 21, 2007, 7:37pm UTC](https://www.ruby-forum.com/t/generating-a-form-using-form-tag-remote-form-tag-in-an-rjs-template/123852/3 "2007-12-21T19:37:49Z")

</div>

Thanks, that seemed to do the trick, although I’m not clear on why the  
partial is required for this to work. Oh well…

On Dec 21, 1:51 am, Thorsten M. \<rails-mailing-l…@andreas-
