Use case: Database entries are represented in a table. By grabbing and moving a row up or down the table, you can change the entries' order/position. The changes are submitted automatically via ajax.
- Uses jQueryUI (custom download: sortable is needed)
- newly created elements are added to the top (see route /jobs/create)
Thanks for sharing!
I'm curious though... If you are saving
position
right on the Job itself, then changing position of one item means a bunch of other items' positions will be edited in the process. What if you want to offer ability to also order byupdated_at
? Now ordering byupdated_at
won't show an accurate representation of actual Job edits, because they'll be re-timestamped every time you perform a reposition.I guess you could have a Model observer which would listen for position-only item edits, and pass in the original
updated_at
to prevent it from being re-timestamped.How would you handle this?