# Application Helper and Javascript

**URL:** <https://www.ruby-forum.com/t/application-helper-and-javascript/53115>\
**Category:** Rails\
**Created:** [January 25, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/application-helper-and-javascript/53115 "2006-01-25T19:04:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [January 25, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/application-helper-and-javascript/53115/1 "2006-01-25T19:04:14Z")

</div>

I have a “javascript\_include\_tag” including a Javascript function.  
I have a function being invoked via a helper in the same view, which  
prints  
out a script tag that uses the javascript function above.

Problem is, the function being invoked via the helper can’t find the  
javascript function included in the “javascript\_include\_tag”.

I hardcoded the javascript that exists in the “javascript\_include\_tag”,  
into  
the head of the view… and the helper had no problem finding the  
method.  
So… it seems that the helper is being invoked before the  
“javascript\_include\_tag” declaration ?

Does this seem correct ?

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [January 25, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/application-helper-and-javascript/53115/2 "2006-01-25T20:30:28Z")

</div>

Why not just include the javascript file in the tag? Can you post  
the code you are using?

-Jonny.

Dylan S. wrote:

> I have a “javascript\_include\_tag” including a Javascript function.  
> I have a function being invoked via a helper in the same view, which  
> prints  
> out a script tag that uses the javascript function above.
> 
> Problem is, the function being invoked via the helper can’t find the  
> javascript function included in the “javascript\_include\_tag”.
> 
> I hardcoded the javascript that exists in the “javascript\_include\_tag”,  
> into  
> the head of the view… and the helper had no problem finding the  
> method.  
> So… it seems that the helper is being invoked before the  
> “javascript\_include\_tag” declaration ?
> 
> Does this seem correct ?

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [January 25, 2006, 10:08pm UTC](https://www.ruby-forum.com/t/application-helper-and-javascript/53115/3 "2006-01-25T22:08:45Z")

</div>

Jonathan… SVN problem, and my Javascript wasn’t updated. It all works  
now.  
One sec… going to go bury my head in the sand real quick 🙂

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [January 25, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/application-helper-and-javascript/53115/4 "2006-01-25T22:35:19Z")

</div>

It happens to all of us 😉

-Jonny.

Dylan S. wrote:

> Jonathan… SVN problem, and my Javascript wasn’t updated. It all works  
> now.  
> One sec… going to go bury my head in the sand real quick 🙂
