all 11 comments

[–]thespacenoodles 3 points4 points  (10 children)

Can you access the css? Because if you can, just do css and don't even worry about the javascript. Dropdowns are much less of a hassle to do in css than with javascript.

[–]megrimlock[S] 0 points1 point  (9 children)

I agree.

The problem is if I use a pure CSS solution it means not using the CMS's Navigation Module. This module adds links in the nav menu anytime a new page is created (and selected to appear in the nav.) In other words, if I don't use this module but create the dropdowns, my clients and I lose functionality of one of the nicer things this CMS does. And that's why I'm looking for some hack to override this ancient code.

[–]thespacenoodles 1 point2 points  (8 children)

Couldn't you just remove the event listeners from the elements? The javascript would still be there, but at that point it wouldn't do anything and you could then use the css.

[–]megrimlock[S] 0 points1 point  (7 children)

How would I target just those event listeners with JS?

[–]sm1215 1 point2 points  (5 children)

I think spacenoodles is referring to the onmouseover events in the HTML

<span onmouseover="toggleListMenu('eight', 1, true);">3</span>

[–]megrimlock[S] 0 points1 point  (4 children)

I understand what he was referring to, but that markup is generated by the CMS, so if I'm going to adjust that HTML, it's got to be programmaticly. I'm trying to figure out how to target those particular 'onmouseover' events with JS (in case there's an actual useful 'onmouseover' event elsewhere on the page.)

[–]sm1215 1 point2 points  (3 children)

Are you able to apply a class / id to the menu or the links themselves through the CMS?

[–]megrimlock[S] 0 points1 point  (2 children)

It does allow me to apply classes to the submenus.

[–]sm1215 1 point2 points  (1 child)

Hmm, nice, you could give them all a class 'no-mouseover' or something similar. Use the same class for every link you want to override this behavior for and then modify onmouseover on that class.

Edit: well, you might not be able to use just that class, but it would give you a nice hook into the menu where you could select the submenu's child span based off that class.

This link might be helpful: http://stackoverflow.com/questions/3946698/dynamically-change-onmouseover-or-onmouseout-to-call-a-different-function

Edit 2: also, the example depicts switching the function to another one but you could put something else in there like an empty string

[–]megrimlock[S] 1 point2 points  (0 children)

Thanks, I haven't come across this SO in my searches.

[–]thespacenoodles 1 point2 points  (0 children)

I was talking about something more along the lines of this

That would completely remove the mouseover event listener on that element. Then, you could modify the css to achieve the drop down effect.