jQuery on Rails: A (Still Very Alpha) Update

I've made a number of updates to my preliminary release of jQuery on Rails:

  • It's now in svn as part of a demo app, so you can see how it all fits together.
  • The new svn URL is http://jqueryjs.googlecode.com/svn/trunk/tools/railsdemoapp for the entire demo, or http://jqueryjs.googlecode.com/svn/trunk/tools/railsdemoapp/vendor/plugins/jqueryonrails for just the plugin
  • I added a number of new JavaScript files to get copied when you install the plugin.
  • Your jQuery modules now need to be in app/public/javascripts/jquery_modules, which allows the core library files to be separate from your modules

And the big news...

I've written a few proof of concept helpers for jQuery on Rails that come with modules that are automatically installed in jquery_modules. So far, I wrote one for a tabbed interface and one for sortable tables. They both take the same settings as the underlying JavaScript libraries. For instance, you can set up the table sorter as follows:

<% sortable_table :sort_class_asc => "ascending", :sort_class_desc => "descending", :striping_row_class => ["even", "odd"], :stripe_rows_on_start_up => true do %>  
  <thead>
    <tr><th>Col 1</th><th>Col 2</th></tr>
  </thead>
  <tbody>
    <tr><td>jQuery 1.0</td><td>$100</td></tr>
    <tr><td>jQuery 1.1</td><td>$59</td></tr>
    <tr><td>jQuery 1.1.1</td><td>$68</td></tr>
    <tr><td>jQuery 1.1.2</td> <td>$8</td></tr>
  </tbody>
<% end %>  

This corresponds to:

tableSorter({  
  sortClassAsc: 'ascending',
  sortClassDesc: 'descending',
  stripingRowClass: ['even', 'odd'],
  stripeRowOnStartup: true
})

You can check out both the tablesorter helper and the tabs helper in action by checking out the jQuery on Rails demo app.