diff --git a/admin_menu.js b/admin_menu.js
index 169eba8..eb9aa05 100644
--- a/admin_menu.js
+++ b/admin_menu.js
@@ -85,10 +85,11 @@ Drupal.behaviors.adminMenuCollapsePermissions = {
           });
         });
       });
-      // Get fragment from current URL.
-      var fragment = window.location.hash || '#';
       // Collapse all but the targeted permission rows set.
-      $modules.not(':has(' + fragment + ')').trigger('click.admin-menu');
+      if (window.location.hash.length) {
+        $modules = $modules.not(':has(' + window.location.hash + ')');
+      }
+      $modules.trigger('click.admin-menu');
     }
   }
 };
diff --git a/admin_menu.module b/admin_menu.module
index 32ed441..3436585 100644
--- a/admin_menu.module
+++ b/admin_menu.module
@@ -241,6 +241,21 @@ function admin_menu_page_build(&$page) {
 }
 
 /**
+ * Implements hook_overlay_child_initialize().
+ *
+ * @todo Consider to move the tweak_modules/tweak_permissions settings from
+ *   admin_menu_page_build() into hook_form_FORMID_alter() implementations.
+ */
+function admin_menu_overlay_child_initialize() {
+  $page = array();
+  admin_menu_page_build($page);
+  if (!isset($page['page_bottom']['admin_menu']['#attached'])) {
+    return;
+  }
+  drupal_process_attached($page['page_bottom']['admin_menu']);
+}
+
+/**
  * Suppress display of administration menu.
  *
  * This function should be called from within another module's page callback
