Josh (the blog)

I’ve delivered simple, clear and easy-to-use services for 20 years, for startups, scaleups and government. I write about the nerdy bits here.


@joahua

RTFHTMLD!

I’ve been hacking a JavaScript dropdown menu for a client’s site on and off over the last few days, but only finally sat down with a view to fixing the crazy thing this evening. My goodness. You know those moments where you kick yourself so hard you pity the chair you were sitting in? Okay, so I sit in front of my computer too much, but you get the point. This is like… ouch. ARRRRRRRGGGGGGGGHHHHHHHH!!!! Calm is good.

A note, for anyone who is looking to implement not-overly-documented dropdown menus – read your base source file in its entirety before even contemplating trying to implement. It was two lines. Two bloody lines of JavaScript which turned into a ~1 hour nightmare search – not to mention time which I haven’t counted, because it was hackish, not goal-oriented coding. Of course, the longer spent, the more it hurts to find out exactly what I’d missed.

  var ddmx = new DropDownMenuX('topnav');
  ddmx.init();

Those two lines. So much pain!

Oh, and just to clear up any confusion, the acronym which is the title of this news post ends in D, for “Document”. Not “dotcom” or anything stupid like that ;)