Agile Web Development

Build it. Launch it. Love it.

Cascading Javascripts

Cascading Javascripts is a plugin that enhances the behaviour of the built-in javascript_include_tag macro. If :defaults is passed as a parameter, the javascript_include_tag macro will load the following javascript files (if present) in order:

  1. application.js; and
  2. #{controller_name/action_name}.js (eg. home/index.js, customers/new.js, etc.).

This allows you to define application-wide and page-specific javascript files without needing to manually include each one.

To use, simply call javascript_include_tag from application.rhtml including :defaults as a (or the only) parameter:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

      ...
      <%= javascript_include_tag :defaults %>

      ...

See Also

  • Cascading Stylesheets (cascading_stylesheets).

Vitals

Home http://www.redhillconsulting.com.au/rails_plugins.html
Repository svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/cascading_javascripts
License Rails' (MIT)
Tags Tag_red
Rating (1 vote)
Owner Red Hill Consulting
Created 26 May 2006

Comments

  • Avatar
    Jan
    10 December 2008

    This plugin doesn't work with Rails 2.2. You can get a fixed version here: http://github.com/jeanmartin/cascadingjavascriptsreloaded/tree/master

Add a comment