Sortable Tables

Rails has a helper function called sortable_element that generates ajax code to allow you to sort lists by dragging and dropping elements. The function defaults to handle lists and if you want to sort tables you should take note of the :tag option.

<%= sortable_element 'my_list',
:url => { :action => "order" },       
:tag => 'tr' %>

This should allow you to sort tables and hopefully save you from a big headache.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: