Topic: Rails and other Javascript frameworks

Ok, this is like a "pre-newbie" question, since I'm not actually a programmer (I'm just a wannabe fanboy--I know, I realize the irony in that, or the, er, patheticality (sic)).

Anyway, I know Rails ships with Prototype and Scriptaculous, but how well does it play with other Javascript frameworks?  I have a project (php-based) where we're using jQuery for some of the AJAX effects (mostly the lightbox-style popup thinger--I think we're using the thickbox--and some nifty slide ins).  It's a really great little framework, and from what I'm told it's smaller and easier to use than Prototype.  But how easily can you switch to another framework in Rails?

In an upcoming RoR project (with Vinnie and Kelli), I'd hate for us to be tied down to Prototype and Scriptaculous if there are better solutions for our project available.  (There are some great things in the Yahoo UI library that I might like to use... especially their rating design pattern.)

So, please excuse my ignorance on the subject! smile

Josh Catone helps run this place
Rails Forum - Rails Jobs

Re: Rails and other Javascript frameworks

The Ajax helper methods in Rails rely a lot on Prototype and Scriptaculous, but this is only a sliver of Rails and you can simply not use the helper methods in your views and call whatever JavaScript functions you want. You can even create your own helper methods which take advantage of the other frameworks. Thanks to the flexibility of Ruby, you can even override the current helper methods with your own. You can probably do the same with RJS to make it work with any framework, but I imagine this would be a big job.

The question I would have though, is why? For 99% of the AJAX work you won't even need to touch Prototype (or even JavaScript for that matter). The Rails helper methods basically act as a wrapper around JavaScript so you are basically writing JavaScript using Ruby.

If Prototype or Scriptaculous is missing a feature, probably the easiest thing would be to modify the code from the other framework to be compatible with Prototype and add it to your personal library of JavaScript functions. You can then apply helper methods to use the feature and extend RJS to take advantage of it. This seems like a more practical solution than attempting to replace Prototype with another JavaScript framework.

I honestly haven't tried jQuery or many other JavaScript frameworks for that matter, so take what I say with a grain of salt. smile

Railscasts - Free Ruby on Rails Screencasts