Using rjs

Hi

I am relatively new to ruby on rails. I want to use this javascript
bundle:
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

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

-Brian

Woops, I mean
<%= javascript_include_tag “library_name_here” %>

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:
http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html

-Brian

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/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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

page << ‘javascript code goes here’

_Kevin

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/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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

page << ‘javascript code goes here’

_Kevin

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

-Brian

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs