Yehuda Katz is a member of the Ember.js, Ruby on Rails and jQuery Core Teams; his 9-to-5 home is at the startup he founded, Tilde Inc.. There he works on Skylight, the smart profiler for Rails, and does Ember.js consulting. He is best known for his open source work, which also includes Thor and Handlebars. He travels the world doing open source evangelism and web standards work.

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/rails_demo_app for the entire demo, or http://jqueryjs.googlecode.com/svn/trunk/tools/rails_demo_app/vendor/plugins/jquery_on_rails 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'], 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.. http://www.jeremydurham.com/

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:
http://localhost:3000/rails_demo
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

Archives

Categories

Meta