Author: piquadrat
Date: Thu Feb 26 13:53:47 2009
New Revision: 371

Modified:
    trunk/pages/media/pages/javascript/change_list.js

Log:
cache sub_menu in javascript, avoids asking the server for the same sub_menu
multiple times when re-expanding parts of the tree


Modified: trunk/pages/media/pages/javascript/change_list.js
==============================================================================
--- trunk/pages/media/pages/javascript/change_list.js   (original)
+++ trunk/pages/media/pages/javascript/change_list.js   Thu Feb 26 13:53:47  
2009
@@ -41,6 +41,7 @@
      }
  };

+var submenu_cache = new Array();

  $(document).ready(function() {

@@ -165,11 +166,17 @@
              var the_id = jtarget.attr('id').substring(1);
              jtarget.toggleClass('expanded');
              if(jtarget.hasClass('expanded')) {
-                $.get("/admin/pages/page/"+the_id+"/sub-menu/",
-                    function(html) {
-                        $('#page-row-'+the_id).after(html);
-                    }
-                );
+                if (submenu_cache[the_id]){
+                    $('#page-row-'+the_id).after(submenu_cache[the_id]);
+                } else {
+                    $.get("/admin/pages/page/"+the_id+"/sub-menu/",
+                        function(html) {
+                            $('#page-row-'+the_id).after(html);
+                            submenu_cache[the_id] = html;
+                            /* TODO: recursively re-expand submenus  
according to cookie */
+                        }
+                    );
+                }
              } else {
                  remove_children(the_id);
              }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to