Get the order of list item in jquery sortable

后端 未结 5 594
后悔当初
后悔当初 2021-02-04 12:34

I have done this http://jsbin.com/UBezOVA/1/edit.

When I click the submit button, i want to get the current order of the list item. But, it seems that $(\"#sortab

5条回答
  •  灰色年华
    2021-02-04 13:20

    The documentation of toArray of Soratble [link here] clearly says that it Serializes the sortable's item id's into an array of string.

    That means, you should use your sortable elements with an id for each one

    • Item 1
    • Item 2
    • Item 3
    • Item 4
    • Item 5

    And now your code var idsInOrder = $("#sortable2").sortable('toArray'); alert(idsInOrder); will definitely output an array.

提交回复
热议问题