Michael
Michael

Reputation:

jQuery UI sortable: load order from array

Is there a convenient way to load the order of a stored jQuery UI Sortable list?

I'd prefer not to do this server side (extra complication/work for the server), and since the only users that would be resorting the list will have javascript, might as well utilize javascript to reorder it on page load.

The desired scenario:

Any ideas? I think this question will benefit a LOT of users, so I'm hoping for a very elegant, simple solution (no messy hacks like deleting a stock list then appending the configuration to a new one). Preferably something that just looks at an array of IDs and (as best as possible (some items may be added, some may be removed)) and puts them in the same order.

Thanks! =]

Upvotes: 3

Views: 3573

Answers (1)

Yasen Zhelev
Yasen Zhelev

Reputation: 4045

You will have to reorder it after the page loads the way you want it. And you will have to build the array for the client side ordering on the server side any way.

I think it is better to just show the sortable items in the way they should appear on the server side. The list should be static HTML (friendly to non-js clients) you said that, right?

If you really insist to do it on the client browser (with which I disagree), read that - jQuery.sortable. change the order by JS

Upvotes: 1

Related Questions