Chapter 13. Prototype, Scriptaculous, and Rails

 

This chapter covers

  • Understanding the Rails approach to generating JavaScript on the server
  • Using the Rails Ajax helpers to work with Prototype and Scriptaculous
  • Accessing Scriptaculous’s advanced features from Rails
  • Using Rails RJS templates to solve the multiple-update problem, and for other advanced techniques

Our main aim in this book has been to explore Prototype and Scriptaculous as standalone JavaScript libraries, independent of any server-side technologies. In our opinion, these libraries can increase your productivity in developing Ajax solutions with any server-side stack. However, there is no getting away from the fact that both Prototype and Scriptaculous are strongly allied with the Ruby on Rails framework. As a result of this alliance, they have been designed to play well with Rails in several ways, and in this chapter, we’re going to explore the key features that Rails provides that make the use of Prototype and Scriptaculous even smoother.

This isn’t the time or place to provide a full discussion of the Ruby on Rails framework—there are already very good books providing depth of coverage in that area. However, for those who have never come across Rails, here’s a brief description from the rubyonrails.org website:

13.1. Generating JavaScript

13.2. Ajax helpers

13.3. Scriptaculous helpers

13.4. To JavaScript or not to JavaScript

13.5. The next level: RJS

13.6. Summary