jQuery.sortable. change the order by JavaScript

html, html-lists, jquery, sorting

Solution

As Sparr has said, there's no way to sort them using `sortable` directly, but you can still move them manually with something like:

$("#mylist li:eq(1)").insertAfter($("#mylist li:eq(2)"));

Problem

How can I change the order of a list once applied by JavaScript `jQuery.sortable`. For example: ``` <ul id="mylist"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> ``` ``` var x_sortable_list = $("mylist").sortable(); ``` Then, assuming this to work: ``` x_sortable_list.changeOrder([ {item:1, newOrder:2 }, {item:2, newOrder:1 }, {item:3, newOrder:3 } ]); ```

Original source