Yehuda Katz is a member of the Ember.js, Ruby on Rails and jQuery Core Teams; he spends his daytime hours at the startup he founded, Tilde Inc.. Yehuda is co-author of best-selling jQuery in Action and Rails 3 in Action. He spends most of his time hacking on open source—his main projects, like Thor, Handlebars and Janus—or traveling the world doing evangelism work. He can be found on Twitter as @wycats and on Github.

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 for the entire demo, or 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 %>
<th>Col 1</th>
<th>Col 2</th>
<td>jQuery 1.0</td>
<td>jQuery 1.1</td>
<td>jQuery 1.1.1</td>
<td>jQuery 1.1.2</td>
<% end %>

This corresponds to:

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

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

7 Responses to “jQuery on Rails: A (Still Very Alpha) Update”

Keep up the good work, I’m really looking forward to using JQuery in Rails. :-)

freakin’ badass! keep up the good work.

very cool! yes jquery + rails (or merb?)

Jeremy Durham seems to have picked up the jquery+rails torch..

Unfortunately, that plugin uses inline JS via stuff like :onclick, so while it’ll work just fine, it won’t be very jQuery-ish :)

Good luck Jeremy!

checked out the full project.
Now using rails 1.2.5 and Hpricot 0.6
The demo crashes.
When viewing:
Error message begins with:

undefined method `[]' for #

RAILS_ROOT: script/../config/..

...path/to/my/ projects/folder/JQueryDemoApp/vendor/plugins/jquery_on_rails/lib/jqor_control.rb:18:in `get_jquery_files'

This block around line 18 in jqor_control.rb seems quite compilcated. Could’nt it be expanded?

Anyway, Is there a way to solve this bug?

Leave a Reply