Ruby on Rails + Jquery: Saving data from draggable lists
- by sjsc
Hello. I'm trying to save data to the MySQL database in Rails when the user drags items from different lists. I'm using the below Jquery script and HTML:
<script>
$(document).ready(function() {
$("#draggable").draggable( { connectToSortable: 'ul#myList', helper:'clone' } );
$("#myList").sortable();
});
</script>
HTML:
<ul>
<li id="draggable">Drag me to myList</li>
</ul>
<ul id="myList">
<li id="item-1">item 1</li>
<li id="item-2">item 2</li>
</ul>
I know I probably have to use something like this:
$.post({
url: 'lists/update',
data: $('#myList').sortable("serialize")
});
I've been Googling for the last few hours but can't seem to find how to save data between multiple lists using Rails. Any idea?