Browse Source

* Port from 6.x changes. Check that $(element) is not empty to proceed.

Alexis Wilke 14 years ago
parent
commit
000cc37f2f
1 changed files with 8 additions and 2 deletions
  1. 8 2
      simplemenu.js

+ 8 - 2
simplemenu.js

@@ -11,9 +11,17 @@ Drupal.behaviors.simplemenuAttach = {
     if ($('body').hasClass('simplemenu-enabled')) {
       return;
     }
+    $('body').addClass('simplemenu-enabled');
+    
   
     // get the element to add the menu to
     var element = settings.simplemenu.element;
+    if ($(element).length == 0) {
+      // this happens when you open a pop-up or a different theme
+      // that does not have such an element or the named element
+      // just does not exist in the first place.
+      return;
+    }
     var menu = $(simplemenu);
   
     switch (settings.simplemenu.placement) {
@@ -28,8 +36,6 @@ Drupal.behaviors.simplemenuAttach = {
         break;
     }
   
-    $('body').addClass('simplemenu-enabled');
-    
     var animation = {};
     animation[settings.simplemenu.effect] = 'toggle';