# Add ":complete =\> "eval(...)" in form\_remote\_tag

**URL:** <https://www.ruby-forum.com/t/add-complete-eval-in-form-remote-tag/93118>\
**Category:** Rails\
**Created:** [April 27, 2007, 8:53pm UTC](https://www.ruby-forum.com/t/add-complete-eval-in-form-remote-tag/93118 "2007-04-27T20:53:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anakintang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@anakintang](https://www.ruby-forum.com/u/anakintang)\
**Post date:** [April 27, 2007, 8:53pm UTC](https://www.ruby-forum.com/t/add-complete-eval-in-form-remote-tag/93118/1 "2007-04-27T20:53:57Z")

</div>

All,

I was trying to use “form\_remote\_tag” to submit a form Ajax and also I  
want some javascript code generated by the target view being executed  
when the Ajax call is complete. I used following code

\<%= form\_remote\_tag(:url =\> {:action =\> :create}), :complete =\>  
“eval(request.responseText)”%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Save’ %\>  
\<%= end\_form\_tag %\>

But the for\_remote\_tag won’t even being rendered, do I miss something  
here?

Thanks

---

<div class="post-metadata">

**Author:** ![anakintang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@anakintang](https://www.ruby-forum.com/u/anakintang)\
**Post date:** [April 27, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/add-complete-eval-in-form-remote-tag/93118/2 "2007-04-27T21:15:29Z")

</div>

anakintang wrote:

> All,
> 
> I was trying to use “form\_remote\_tag” to submit a form Ajax and also I  
> want some javascript code generated by the target view being executed  
> when the Ajax call is complete. I used following code
> 
> \<%= form\_remote\_tag(:url =\> {:action =\> :create}), :complete =\>  
> “eval(request.responseText)”%\>  
> \<%= render :partial =\> ‘form’ %\>  
> \<%= submit\_tag ‘Save’ %\>  
> \<%= end\_form\_tag %\>

What version of rails are you using? For rails 1.2+ you should use  
\<% form\_remote\_tag %\>  
and NOT  
\<%= form\_remote\_tag %\>

My guess is you are on rails 1.1+. Any reason why you are not using 1.2?

What is generated in the html page (View source) for the form?

---

<div class="post-metadata">

**Author:** ![anakintang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@anakintang](https://www.ruby-forum.com/u/anakintang)\
**Post date:** [April 28, 2007, 12:14am UTC](https://www.ruby-forum.com/t/add-complete-eval-in-form-remote-tag/93118/3 "2007-04-28T00:14:19Z")

</div>

Chet Sanders wrote:

> anakintang wrote:
> 
> > All,
> > 
> > I was trying to use “form\_remote\_tag” to submit a form Ajax and also I  
> > want some javascript code generated by the target view being executed  
> > when the Ajax call is complete. I used following code
> > 
> > \<%= form\_remote\_tag(:url =\> {:action =\> :create}), :complete =\>  
> > “eval(request.responseText)”%\>  
> > \<%= render :partial =\> ‘form’ %\>  
> > \<%= submit\_tag ‘Save’ %\>  
> > \<%= end\_form\_tag %\>
> 
> What version of rails are you using? For rails 1.2+ you should use  
> \<% form\_remote\_tag %\>  
> and NOT  
> \<%= form\_remote\_tag %\>
> 
> My guess is you are on rails 1.1+. Any reason why you are not using 1.2?
> 
> What is generated in the html page (View source) for the form?

I am using 1.2.3 rails. What is the new syntax? Just take out “=” like  
below?

\<% form\_remote\_tag(:url =\> {:action =\> :create}), :complete =\>  
“eval(request.responseText)”%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Save’ %\>  
\<% end\_form\_tag %\>

---

<div class="post-metadata">

**Author:** ![anakintang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5fc32e/32.png) [@anakintang](https://www.ruby-forum.com/u/anakintang)\
**Post date:** [April 28, 2007, 12:32am UTC](https://www.ruby-forum.com/t/add-complete-eval-in-form-remote-tag/93118/4 "2007-04-28T00:32:33Z")

</div>

anakintang wrote:

> Chet Sanders wrote:
> 
> > anakintang wrote:
> > 
> > > All,
> > > 
> > > I was trying to use “form\_remote\_tag” to submit a form Ajax and also I  
> > > want some javascript code generated by the target view being executed  
> > > when the Ajax call is complete. I used following code
> > > 
> > > \<%= form\_remote\_tag(:url =\> {:action =\> :create}), :complete =\>  
> > > “eval(request.responseText)”%\>  
> > > \<%= render :partial =\> ‘form’ %\>  
> > > \<%= submit\_tag ‘Save’ %\>  
> > > \<%= end\_form\_tag %\>
> > 
> > What version of rails are you using? For rails 1.2+ you should use  
> > \<% form\_remote\_tag %\>  
> > and NOT  
> > \<%= form\_remote\_tag %\>
> > 
> > My guess is you are on rails 1.1+. Any reason why you are not using 1.2?
> > 
> > What is generated in the html page (View source) for the form?
> 
> I am using 1.2.3 rails. What is the new syntax? Just take out “=” like  
> below?
> 
> \<% form\_remote\_tag(:url =\> {:action =\> :create}), :complete =\>  
> “eval(request.responseText)”%\>  
> \<%= render :partial =\> ‘form’ %\>  
> \<%= submit\_tag ‘Save’ %\>  
> \<% end\_form\_tag %\>

Now I changed to use the new syntax and it works fine. Thanks a lot!

\<% form\_remote\_tag(:url =\> {:action =\> :create}, :complete =\>  
“eval(datasets\_tab\_handler())”) do -%\>  
\<%= render :partial =\> ‘form’ %\>  
\<%= submit\_tag ‘Save’ %\>  
\<% end -%\>
