$('.dd').nestable('serialize');
$('.dd').on('change', function() {
$.post(
$(this).data('update-url'),
$(this).nestable('serialize')
)
});
.dd data-update-url="#{sort_admin_list_pages_path(@list)}"
ol.dd-list
- @list.pages.order('position').each do |page|
li.dd-item data-id="#{page.id}"
.dd-handle = page.name
def sort
params[:pages].each_with_index do |id, index|
Page.where(id: id).update_all({position: index+1})
end
render nothing: true
end