1

I cannot find in the JQUI documentation how to display the sort order. What I want to do is display the sort order i.e. 1,2,3, 4, etc as a visual reference for a user. The sort order obviously updates on a sort, just not sure how to find/get the sort order - Oh I'm not sorting <li>'s

2 Answers 2

1

You can do it youself, just recalculate order on each stop event of sortable element:

... 
 stop: function (event, ui) {
                setOrder();
            },
...
function setOrder() {
 $("#liContainerId").each(function (index,li) {
  // set display order here
});
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use the toArray method of sortables: https://api.jqueryui.com/sortable/#method-toArray

Assuming this is your sortable, you can use the following code to retrieve an array of DOM IDs of the sortable's items in sort order:

var arrayOfIds = $(this).sortable("toArray")

Use it in the Stop event handler to update a display, like Andrew suggested. Check the linked documentation if you want to retrieve another attribute rather than the ID.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.