# JS functions from partial not available?

**URL:** <https://www.ruby-forum.com/t/js-functions-from-partial-not-available/103755>\
**Category:** Rails\
**Created:** [May 9, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/js-functions-from-partial-not-available/103755 "2007-05-09T23:45:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johannes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ba0ec/32.png) [@johannes](https://www.ruby-forum.com/u/johannes)\
**Post date:** [May 9, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/js-functions-from-partial-not-available/103755/1 "2007-05-09T23:45:14Z")

</div>

hey!

clicking “login” opens (ajax) a login form (partial) on my site.

this partial includes the form and javascript block.  
looks like this:

the problem is: if i try to call the validate-function from inside the  
form (\<input onkeyup=“validate()”…) i’m getting a js error:

validate() is not defined

Why isn’t that function available on my site after the partial is loaded  
?

thx alot

---

<div class="post-metadata">

**Author:** ![johannes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ba0ec/32.png) [@johannes](https://www.ruby-forum.com/u/johannes)\
**Post date:** [May 9, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/js-functions-from-partial-not-available/103755/2 "2007-05-09T23:56:12Z")

</div>

Johannes wrote:

> hey!
> 
> clicking “login” opens (ajax) a login form (partial) on my site.
> 
> this partial includes the form and javascript block.  
> looks like this:
> 
> the problem is: if i try to call the validate-function from inside the  
> form (\<input onkeyup=“validate()”…) i’m getting a js error:
> 
> validate() is not defined
> 
> Why isn’t that function available on my site after the partial is loaded  
> ?
> 
> thx alot

Rendering a partial with Ajax usually requires the evalScripts parameter  
([Prototype API Documentation | String#evalScripts (Deprecated URL)](http://prototypejs.org/api/string/evalScripts)).

I’d give that a try, otherwise just include that javascript method in  
the initial page where you render the login form, that way the  
javascript will surely be evaluated.

Hope that helps,

- Eric
