# RJS call in :complete of form\_remote\_tag

**URL:** <https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084>\
**Category:** Rails\
**Created:** [June 17, 2007, 11:39pm UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084 "2007-06-17T23:39:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [June 17, 2007, 11:39pm UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084/1 "2007-06-17T23:39:23Z")

</div>

Hi,

this should be easy:

I have a “test.rjs” and I want to call it from the :complete of a  
form\_remote\_tag.

How would I do that?

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [June 17, 2007, 11:55pm UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084/2 "2007-06-17T23:55:24Z")

</div>

Hi Max,

Max wrote:

> I have a “test.rjs” and I want to call it from the :complete  
> of a form\_remote\_tag.
> 
> How would I do that?

I’m not sure you can. I’m pretty sure that the callback options on  
form\_remote\_tag are only useful for calling javascript that’s already in  
the  
page that’s loaded in the browser.

Bill

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [June 18, 2007, 12:37am UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084/3 "2007-06-18T00:37:28Z")

</div>

> I’m not sure you can. I’m pretty sure that the callback options on  
> form\_remote\_tag are only useful for calling javascript that’s already in the  
> page that’s loaded in the browser.

So where should I put the code instead?

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [June 18, 2007, 6:35am UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084/4 "2007-06-18T06:35:56Z")

</div>

Use a form\_remote tag and then post it to the controller. Call an RJS  
action from there. That should work.

Vish

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [June 18, 2007, 2:28am UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084/5 "2007-06-18T02:28:35Z")

</div>

Hi Max,

Max wrote:

> > I’m not sure you can. I’m pretty sure that the callback  
> > options on form\_remote\_tag are only useful for calling  
> > javascript that’s already in the page that’s loaded in the  
> > browser.
> 
> So where should I put the code instead?

That would depend on what you’re trying to do. You didn’t post the .rjs  
so  
I can’t say for sure. In general, given what you’ve said, if you want  
to  
execute javascript on completion of the form submission, I’d say write  
the  
javascript, put it in application.js, and it’ll be available to you on  
:complete.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [June 20, 2007, 11:21am UTC](https://www.ruby-forum.com/t/rjs-call-in-complete-of-form-remote-tag/107084/6 "2007-06-20T11:21:57Z")

</div>

> Use a form\_remote tag and then post it to the controller. Call an RJS  
> action from there. That should work.

Thanks, I solved my initial problem in a completely different way, but  
I’ll come back to it and try that.
