Introducing script.aculo.us (Page 1 of 4 )
Rails can be used with more than Ruby. In this three-part series, you'll find out about the visual effects you can do with script.aculo.us on Rails. It is excerpted from chapter four of the book
Ajax on Rails, written by Scott Raymond (O'Reilly, 2007; ISBN: 0596527446).
Most of the last chapter dealt with the Rails helpers that interact with Prototype. In this chapter, we’ll shift attention to script.aculo.us, and the Rails helpers that use it. script.aculo.us provides eye-catching visual effects and transitions and powerful drag-and-drop elements.
The relationship between Prototype and script.aculo.us is close. They’re both developed in concert with Rails, and they share very similar coding styles and APIs. In fact, some of what is now script.aculo.us was originally part of Prototype. Despite the close ties, the two libraries have different goals. Prototype is designed to be an extension of JavaScript—it provides features that arguably ought to be part of the core language, such as convenient methods for data structures, DOM interaction, and easy Ajax calls. On the other hand, script.aculo.us works at a higher level, closer to the application and UI levels, by providing components built on Prototype. In some cases, those components are surprisingly complex and yet usable with just a few lines of code.
We’ll put the examples for this chapter into a new controller, so from your Rails project directory, run the generator:
script/generate controller chapter4 index
If you already created an application-wide layout (layouts/application.rhtml) and CSS file (public/stylesheets/application.css) from the beginning of Chapter 3, they will automatically be used for this controller as well.
Now let’s take a look at what script.aculo.us is most famous for: its visual effects.
Next: Visual Effects >>
More Ruby-on-Rails Articles
More By O'Reilly Media
|
This article is excerpted from chapter four of the book Ajax on Rails, written by Scott Raymond (O'Reilly, 2007; ISBN: 0596527446). Check it out today at your favorite bookstore. Buy this book now.
|
|