# Calling a javascript function after loading a partial with r

**URL:** <https://www.ruby-forum.com/t/calling-a-javascript-function-after-loading-a-partial-with-r/53383>\
**Category:** Rails\
**Created:** [February 3, 2006, 7:12am UTC](https://www.ruby-forum.com/t/calling-a-javascript-function-after-loading-a-partial-with-r/53383 "2006-02-03T07:12:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [February 3, 2006, 7:12am UTC](https://www.ruby-forum.com/t/calling-a-javascript-function-after-loading-a-partial-with-r/53383/1 "2006-02-03T07:12:32Z")

</div>

Hi,  
Is is possible to call a javascript function once a partial is loaded.  
Here’s what I am doing.  
I have a partial that gets updated via. an ajax call. When the partial  
is updated I want to call a javascript function ( enableTooltips ) which  
will then add tooltips to my links in the newly updated partial.  
Any help would be greatly appreciated.  
Thanks,  
Eric

–  
Eric G.  
[ericgoodwin.com](http://ericgoodwin.com)

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [February 3, 2006, 7:18am UTC](https://www.ruby-forum.com/t/calling-a-javascript-function-after-loading-a-partial-with-r/53383/2 "2006-02-03T07:18:36Z")

</div>

I believe the :complete option will accomplish this for you.

Another method is to stick a script tag in your partial that calls the  
function.

Haven’t used either of these, just recalling from the API docs I read so  
take it as a starting point for your research.

Bob S.  
[http://www.railtie.net/](http://www.railtie.net/)

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [February 3, 2006, 7:30am UTC](https://www.ruby-forum.com/t/calling-a-javascript-function-after-loading-a-partial-with-r/53383/3 "2006-02-03T07:30:39Z")

</div>

Thanks for the help Bob,

Putting the code in the partial works fine in Firefox, but alas IE lets  
up down on this one. It seems that IE doesn’t allow changing HTML tables  
via DOM until they are fully rendered. IE crashes with an “Operation  
Aborted” error. This happens in both IE 6 and the new IE 7 Beta.

The :complete worked perfectly though. I should have known. It’s getting  
late though and my brain isn’t working like it should be.

Thanks again,  
Eric

Bob S. wrote:

> > Hi,  
> > Eric G.  
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Eric G.  
[ericgoodwin.com](http://ericgoodwin.com)
