# Page.call

**URL:** <https://www.ruby-forum.com/t/page-call/178206>\
**Category:** Rails\
**Created:** [October 30, 2009, 7:03pm UTC](https://www.ruby-forum.com/t/page-call/178206 "2009-10-30T19:03:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wtn12049](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@wtn12049](https://www.ruby-forum.com/u/wtn12049)\
**Post date:** [October 30, 2009, 7:03pm UTC](https://www.ruby-forum.com/t/page-call/178206/1 "2009-10-30T19:03:11Z")

</div>

Hi Everyone,

I’m trying to get page.call to work and if i call something like  
page.call ‘alert’, ‘this is a test’  
everything works ok, however when i try calling a function that i  
defined in application.js  
function my\_function(){  
alert(‘this is a test’);  
} i get NameError (undefined local variable or method `my\_function’ for  
#\<ActionView::Base:.

Any idea what i’m doing wrong here. Any input is greatly appreciated.

Thank you,

---

<div class="post-metadata">

**Author:** ![wtn12049](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@wtn12049](https://www.ruby-forum.com/u/wtn12049)\
**Post date:** [October 30, 2009, 8:00pm UTC](https://www.ruby-forum.com/t/page-call/178206/2 "2009-10-30T20:00:45Z")

</div>

On Oct 30, 6:03 pm, Wtn Tn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Any idea what i’m doing wrong here. Any input is greatly appreciated.

What’s in your rjs file ?

Fred

---

<div class="post-metadata">

**Author:** ![wtn12049](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@wtn12049](https://www.ruby-forum.com/u/wtn12049)\
**Post date:** [October 30, 2009, 11:11pm UTC](https://www.ruby-forum.com/t/page-call/178206/3 "2009-10-30T23:11:36Z")

</div>

On Oct 30, 8:06 pm, Wtn Tn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> function my\_function(test){alert(test);}  
>   
> page.call my\_function

Well just as you wrote page.call ‘alert’ and not page.call alert you  
need to write page.call ‘my\_function’ (I’m assuming that script tag  
isn’t actually in your rjs file as that clearly won’t work)

Fred

---

<div class="post-metadata">

**Author:** ![wtn12049](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@wtn12049](https://www.ruby-forum.com/u/wtn12049)\
**Post date:** [October 30, 2009, 9:06pm UTC](https://www.ruby-forum.com/t/page-call/178206/4 "2009-10-30T21:06:42Z")

</div>

Frederick C. wrote:

> On Oct 30, 6:03ï¿½pm, Wtn Tn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Any idea what i’m doing wrong here. Any input is greatly appreciated.
> 
> What’s in your rjs file ?
> 
> Fred

page.call my\_function
