开发者

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:

  • All data is stored as a normal javascript array using persistjs or sent to the client on page load (as a native array).
  • The list should be static HTML (friendly to non-js clients) (and should not be appended to an empty list, as other users in previous questions suggest)
  • If there's no stored preference, nothing happens. The normal list is just left as is.

Any ideas? I think this question will benefit a LOT of users, so I'm hoping for a very elegant,开发者_StackOverflow 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! =]


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜