The Linux Page

Drupal SimpleMenu & Javascript errors

Somehow, once in a while, I just don't get my navigation menu at the top of my screen.

I use the Drupal SimpleMenu module. It works in most cases, yet you have to make sure that your theme include the print $closure before the closing body tag. Something like this:

    ...
    <?php print $closure; ?>
  </body>
</html>

This will print the simplemenu variable. It is a Javascript variable used to create the menu. It is an array tree with all the menus and sub-menus and their corresponding label and URL. Simple stuff... The author uses SuperFish to get everything rendered.

Yet, once in a while, it just plainly breaks. That is, it just does not do anything. The menu does not apepar. I experienced that tonight again and I was wondering why would that be again?! I knew I had the problem before and solved it...

Some of the code on that site had some problems earlier. I fixed those and the menu was still not showing up. Bother!

Then at some point I clicked on my middle mouse button to open the FCKeditor setup in a different window. At the time I closed that new window (really, a tab in my browser) I noticed that the Simple Menu was showing up... So I reopened that window, went to several different pages, the menu is there, on every page! Found the solution!

So... what did happen? I think that because I had a Javascript error when I first opened that page, somehow, the browser kept in its brain this sticky idea that something's wrong and thus it cannot run Javascript on startup until fixed. But even reloads would not fix anything. Opening a new window or tab fixes the problem though.