Posted By

FatFolderDesigner on 03/19/11


jquery sortable

Versions (?)

Saving Nested jQuery sortable lists

 / Published in: jQuery


Nested sortable lists work well for dropdown menu construction pages but unfortunately the sortable function built in save functions don't work to well with them. This function will take all the list element IDs and compine them into an easily breakable string you can send to PHP to save the new order.

This is designed for list that are sorted with a id/parentid system, it's a simple system, if you have any questions about it or this function leave a comments (theres also some more info on the site, leaving comments there might work better)

  1. function update_menu_positions(btnpress){
  2. $("ul.menubuilder:first > li").each(function(){
  3. arr += ','+$(this).attr('id')
  4. if($(this).has('ul')){
  5. subitems($(this).attr('id'));
  6. }
  7. });
  8. function subitems(pid){
  9. $("#"+pid+" > ul.menubuilder:first > li").each(function(){
  10. if($(this).attr('id')!='null'){
  11. arr += ','+$(this).attr('id')+'/'+pid;
  12. }
  13. if($(this).has('ul')){
  14. subitems($(this).attr('id'));
  15. }
  16. });
  17. }
  18. }

Report this snippet  

You need to login to post a comment.