开发者

rails and jquery sortable

im trying to implement a nice gui for organizing posts. i want to use jQuery UI's sortable so the user can drag/drop. i have a column for each post in my database "display order" that i sort by

how can i effectively translate what jque开发者_如何学JAVAry does to the display_order columns in my db?


One step at the time

  1. Attach onchange handler to ui sortable.
  2. Each time order changes, loop through your elements and recalculate their positions.
  3. Save new position data with ajax request, or add a 'save' button for the user to do it later.

edit
but how do I also get the unique IDs
See #2.

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

As for 'expensive', that's your choice. You can add 'save' button, as I noted above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜