Hi,

I'm newbie to JQuery, everything is working fine but I'd like to set the default tree to collapsed, how can i do that?

Thanks

Comments

pwaterz’s picture

if you look in the jquery menu folder, you will find the jquerymeny.module file. Change lines 207 and 208 to closed.

rpadua’s picture

Thanks!! it works like a charm!

Although, is it possible to close an opened branch when you open a new one instead of keeping all opened?

Best xx

mokeefe’s picture

The Module is excellent. I'm using it in one of my sites and I needed it to open only if the page was in the active trail.

The result is a very intuitive navigation. I'm using 6.x-3.0 and think the change would be a good adition to the core module.

Here is the Code (Starting in line 219 from jquerymenu.module):

// If the menu item is expanded or in the active trail and if has children add the "open" class.
if (!empty($item['link']['expanded']) || ((in_array($item['link']['href'], $url_array) || ($_GET['q'] == $item['link']['href'])) && !empty($item['link']['has_children']) && !empty($nextlevel))) {
if(in_array($item['link']['href'], $url_array)){
$classes[] = 'open';
$state = 'open';
}
else{
$classes[] = 'closed';
$state = 'closed';
}

}
elseif (!empty($item['below']) && !empty($nextlevel)) {
$classes[] = 'open';
$state = 'open';
}

I hope you find it interesting.
Regards,
Matías

jlea9378’s picture

I tried the code you provided, but it expands everything in the tree below the top level branch once you go to one of its branches. Is there a way to leave the non-active branches collapsed?

yan’s picture

if you look in the jquery menu folder, you will find the jquerymeny.module file. Change lines 207 and 208 to closed.

Hacking the module isn't the nicest solution. Can't this setting be provided to the settings page?

Hm, checking the file I just noticed that line 209 reads $state = 'closed';. But my top menu item that links to the frontpage is always expanded..

yan’s picture

I just noticed that my problem is caused because the front page is always in active trail. But why? Here it is said that <front> is selected, when active trail is empty: http://drupal.org/node/801270

jlea9378’s picture

Status: Active » Closed (fixed)

Not using this module, so no longer need this open.

hockey2112’s picture

Status: Closed (fixed) » Active

I have the same need. In jquerymenu.module (starting at line 267), I changed this:

      // If the menu item is expanded or in the active trail and if has children add the "open" class.
      if (!empty($item['link']['expanded']) || ((in_array($item['link']['href'], $url_array) || ($_GET['q'] == $item['link']['href'])) && !empty($item['link']['has_children']) && !empty($nextlevel))) {
        $classes[] = 'open';
        $state = 'open';
      }

to this:

      // If the menu item is expanded or in the active trail and if has children add the "open" class.
      if (!empty($item['link']['expanded']) || ((in_array($item['link']['href'], $url_array) || ($_GET['q'] == $item['link']['href'])) && !empty($item['link']['has_children']) && !empty($nextlevel))) {
        $classes[] = 'closed';
        $state = 'closed';
      }

But it had no effect. What I need is to have the menu always be closed, even if the current page is in the active trail. Any help?

Thanks!

chris mcgrath’s picture

subscribing in need of the same behavior need menu to not be expanded on new page load

Bhuvana_Indukuri’s picture

Issue summary: View changes

Need the same behaviour for drupal 7 version of the module

rituraj.gupta’s picture

Comment the starting 4 lines of jquerymenu.js for drupal 7

$('ul.jquerymenu .open').parents('li').removeClass('closed').addClass('open');
$('ul.jquerymenu .open').parents('li').children('span.parent').removeClass('closed').addClass('open').slideDown('700');
$('ul.jquerymenu .active').parents('li').removeClass('closed').addClass('open');
$('ul.jquerymenu .active').parents('li').children('span.parent').removeClass('closed').addClass('open');

Hope this help. :)