Rails and jquery sorting

im trying to implement a good gui for organizing messages. I want to use jQuery UI sortable so that the user can drag / drop. I have a column for each message in my database "display order", which I sort by

how can i effectively translate what jquery does into display_order columns in my db?

+3
source share
1 answer

One step at a time

  • Attach the exchange handler to the ui sort.
  • Each time the order changes, scroll through the elements and recount their positions.
  • Save the new position data using an ajax request or add a “Save” button for the user to do this later.



. № 2.

var rank = 1;
$('.my-element').each(function() {
    $(this).find('input.rank').val(rank++);
});

"", . "", .

+3

Source: https://habr.com/ru/post/1783532/


All Articles