Javascript trouble

Problem #1: You’re assuming that Rails does Javascript. Javascript can only be run by a browser, Rails just has lots of helpers for printing out useful Javascript to the page.

Problem #2: What exactly are you trying to do? RJS is mostly used with AJAX calls (aka you are creating script that gets executed when Ajax.request is called).

And actually, the documentation doesn’t “really suck”, you’re trying to use a feature without understanding how or what it does.

Jason

If you’re serious about learning the ins and outs of Rails, go to your local bookstore and pick up Agile Web Development with Rails. And be sure you’ve looked through the information here: http://rubyonrails.com/docs. There is an ever growing amount of Rails tutorials and information.

There’s not much else I can say here. We are happy to answer specific questions or comments on using Rails. The reason what you are trying to do here doesn’t work touches on the basis of how Rails itself functions. Sorry I can’t be of any more help; please read through this information, it should answer your questions.

Jason

Ugh. I remember how much I hated PHP’s online docs. I’ll take the Rails API site over that anyday.</cents count=“two”>

RSL

Um, what do you mean by “hiding a layer”?

Jason

If you’re looking for documentation about Prototype’s methods then of course the Rails docs are gonna suck. BTW, there’s no documentation about CSS selectors, or HTML frames, or JS function definitions either. :confused: I guess Rails sucks because it isn’t a one-stop shop for all your web application needs like PHP is. :confused:

RSL

I see your point, but for sake of argument, our side of the story is that Rails is built to make web programming easier, not design. Rails is built to take care of the crap that goes into most web programming (propagated mostly by PHP) and to make the process enjoyable. Rails assumes that you know HTML, that you know web technologies and that you know the basics of programming itself. It is not a part of Rails, nor should it be, to offer tutorials or information on Javascript, as there is plenty of that on the web already.

The documentation is sufficient in explaining what the Javascript helpers give you, even to the point of sending you off to Script.taculo.us for the documentation of the Javascript library itself. As a library developer’s point of view, if one had to package up documentation for every bit and piece used in the library, it would be an ungodly huge bloat of documentation text that would quickly be out of date and littering the web with bad copies of said documentation, making everyone’s lives more difficult.

Rails is a change in web development thinking. For someone who’s been with PHP for a long time, it’s understandable if they have a hard time switching, but the time spent is more than worth it.

Again, we are more than happy to answer specific questions about Rails. If you want to know how certain other parts work (Javascript, etc), we can help by pointing you to good documentation.

That’s pretty much the developer’s side of the story.

Jason

Though technically if you’re using Prototype, you can simply do:

Element.hide(‘layer1’);

As for your onload question, what’s wrong with just doing ?

Or if you have a layout and view files:

layout.rhtml:

>

some_action.rhtml

<% content_for(:body_tag) do %> onload=“javascript stuff”

<% end %>

Jason