November 16, 2009

thought for the day

Ever notice how many Rails developer blogs use Wordpress?

November 10, 2009

Rails Sortable Draggable params

Went around in circles a bit today implementing a barely-fancy list-to-list drag 'n sort. I don't do much Ajax usually, so I tend to lose my place, forget little things, and basically keep my Googling skills in tip-top shape to make up for my shoddy memory.

Anyway, enough backstory. You gotta use a word when id'ing your elements in sortable_element. It doesn't even matter what you use:

<li id="adfasjkd_<%= partialname.id %>">

(or however you're generating unique IDs for your LIs)

...as long as you have <ul id="flarfydarf">, Rails seems to be smart enough to chop whatever is not unique in the LI ID and throw it into params[:flarfydarf].

There are plenty of older tutorials out there with regexes in js functions inside the Ajax business, but I don't have any of that and Rails is finding my IDs just fine. Go figure.