i'm trying resort list of jquery sortable , sinatra app. have 1 question. serialize function of sortable generates string new order of list this:
"id[]=15&id[]=16&id[]=14&id[]=17&id[]=18"
when post server on ajax sinatra app understands string. question is, how convert string in sinatra can loop thru?
solved it!
instead of using "serialize" on js side of things used "toarray". loop thru array on sinatra side. here:s js code:
$('.sortable').sortable({ start: function(event, ui) { start = $(ui.item).index(); }, update: function( event, ui ) { item = $(ui.item).attr('id'); end = $(ui.item).index(); var sorted = $('.sortable').sortable("toarray"); $.post("/items/order", { order: sorted } ); console.log (sorted); } });
Comments
Post a Comment