From 000cc37f2fb6f2a539c9392819f9d57c82c11e21 Mon Sep 17 00:00:00 2001 From: Alexis Wilke Date: Tue, 1 Jun 2010 21:09:27 +0000 Subject: [PATCH] * Port from 6.x changes. Check that $(element) is not empty to proceed. --- simplemenu.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/simplemenu.js b/simplemenu.js index 3617e8a7..8d7112d7 100644 --- a/simplemenu.js +++ b/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';