# Using rjs

**URL:** <https://www.ruby-forum.com/t/using-rjs/96692>\
**Category:** Rails\
**Created:** [June 30, 2006, 9:23pm UTC](https://www.ruby-forum.com/t/using-rjs/96692 "2006-06-30T21:23:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 30, 2006, 9:23pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/1 "2006-06-30T21:23:36Z")

</div>

Hi

I am relatively new to ruby on rails. I want to use this javascript  
bundle:  
[http://prototype-window.xilinus.com/index.html](http://prototype-window.xilinus.com/index.html)

How would I call those functions in an rjs file?

example:  
win = new Window(‘window\_id’, {title: “Sample”, top:100, left:350})  
win.getContent().innerHTML = “

# Hello world !!
”;  
win.setDestroyOnClose();  
win.showCenter();

Thanks

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 30, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/2 "2006-06-30T23:18:48Z")

</div>

I think you would use page.call ‘javascript\_to\_be\_evaluated’

with your example I’m guessing something like this would work  
page.call(“win = new Window(‘window\_id’, {title: "Sample", top:100,  
left:350})”)  
etc…etc…  
don’t for get to include the javascript library in your layout  
\<%= include\_javascript\_tag “library\_name\_here” %\>  
And of course, make sure it’s in your rails app javascript folder =)

heres the docs on it:  
[http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html](http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html)

-Brian

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 30, 2006, 11:21pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/3 "2006-06-30T23:21:56Z")

</div>

Woops, I mean  
\<%= javascript\_include\_tag “library\_name\_here” %\>

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2006, 4:57pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/4 "2006-07-03T16:57:25Z")

</div>

Hi,

THanks for the input, but that did not work. Does anyone know how to  
get this to work using rjs?

thanks

Brian Chamberlain wrote:

> I think you would use page.call ‘javascript\_to\_be\_evaluated’
> 
> with your example I’m guessing something like this would work  
> page.call(“win = new Window(‘window\_id’, {title: "Sample", top:100,  
> left:350})”)  
> etc…etc…  
> don’t for get to include the javascript library in your layout  
> \<%= include\_javascript\_tag “library\_name\_here” %\>  
> And of course, make sure it’s in your rails app javascript folder =)
> 
> heres the docs on it:  
> [Peak Obsession](http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html)
> 
> -Brian

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/5 "2006-07-03T17:55:13Z")

</div>

On Monday, July 03, 2006, at 4:57 PM, User wrote:

> > with your example I’m guessing something like this would work
> > 
> > -Brian
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

In an RJS template, I think this outputs JS directly…

page \<\< ‘javascript code goes here’

\_Kevin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2006, 6:22pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/6 "2006-07-03T18:22:15Z")

</div>

That does. and it does work, however, I would like to try it without  
dumping straight up javascript code because i could just do it in js  
instead.

thanks

Kevin O. wrote:

> On Monday, July 03, 2006, at 4:57 PM, User wrote:
> 
> > > with your example I’m guessing something like this would work
> > > 
> > > -Brian
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > * * *
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> In an RJS template, I think this outputs JS directly…
> 
> page \<\< ‘javascript code goes here’
> 
> \_Kevin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/using-rjs/96692/7 "2006-07-03T21:08:08Z")

</div>

On Monday, July 03, 2006, at 6:22 PM, User wrote:

> > > > -Brian
> 
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)  
> The RJS functions like

page.replace\_html

are all helper functions. You could write a set of helper functions  
like that for your JS library and then use them in a similar manner.

\_Kevin
