← Back to Upcase

Dom manipulation and Rails


(Esop) #1

Let’s say I have a list of items in the dom that can be reordered with javascript. How do I allow the user to make another request without affecting their reordering?


(Sean Griffin) #2

You’d probably need to persist their ordering somehow. Depending on what it is you’re doing, you would might be able to do this with the users’ cookies, and reorder them using Javascript when the page loads, or implement a table to order things server side with something like this:

create_table :orderings do |t|
  t.integer :sort
  t.belongs_to :orderable, polymorphic: true
  t.belongs_to :user
end

(Esop) #3

Thanks I’ll try that.