I have only one of my top-level menus that have children and it expands fine, of course. The problem is that the other menu items do not have any children and still expand showing nothing. I don't see anything in the block settings to change this though maybe I'm not understanding the descriptions. How do I accomplish this? It was working in the last version.

Comments

aniebel’s picture

I temporarily fixed this by turning the animation to "false" but it still seems like it should not expand with or without animation if there are no children.

austonian’s picture

Following this issue as it is affecting my implementation of this module.

solotandem’s picture

austonian, are you aware of the green "follow" button at top right? It is still "new" to many.

Any takers on submitting a patch?

chrsnlsn’s picture

I took a look in the module, didn't see an easy way to accomplish a permanent solution. Another short-term workaround for this is to stop the event by targeting the specific accordion header(s) you wish to not have the accordion effect on. It's working for me.

$(".accordion-menu-1 .accordion-header-1").click(function(event){
event.stopImmediatePropagation();
);

ryanfc78’s picture

Chris,

Where do you put this line of code? What file and does anything else need to be before it or after it? Tried copying and pasting a few places, but always got errors.
Thanks.

chrsnlsn’s picture

I started formatting my javascript like the following can be placed and called by your theme or from a theme helper module. Just change 'yourtheme' to your theme or module name and make sure the file is getting called and the correct accordion header is being targeted.

(function ($) {
	Drupal.behaviors.yourtheme = {
	    attach: function (context, settings) {
		  $(".accordion-menu-1 .accordion-header-1").click(function(event){
			 event.stopImmediatePropagation();
		  });
		},	
     };
})(jQuery);
solotandem’s picture

Assigned: Unassigned » solotandem
Status: Active » Fixed

In this commit:
- removed accordion effect on "empty" headers (i.e., headers with no children)
- added empty header icon setting to use on empty headers
- added a plain "accordion-header" class to header elements.

solotandem’s picture

In this commit for 6.x-1.x, document inability to remove accordion effect on "empty" headers when using jQuery UI 1.6 releases (common for Drupal 6). This is due to the event handler being attached to the entire menu as opposed to individual headers as in the 1.8 releases.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

peacog’s picture

Category: Feature request » Bug report
Priority: Major » Normal
Issue summary: View changes
Status: Closed (fixed) » Needs review
StatusFileSize
new550 bytes

I'm reopening this because the unbinding of the accordion for menu items with no children was not working. Here is a patch that fixes it.

swim’s picture

Had the same issue as #10; Peacog's patch looks good.

Jedd Casella’s picture

Patch in #10 worked. Thanks Peacog.

volker23’s picture

The patch #10 doesn't work for me. Do I need a specific combination of jQuery version and CDN? If i select 1.8 and CDN: Jquery, it works almost as expected, but another error occurs, that is the same as described here: https://www.drupal.org/node/2260003

I tried every combination of "with patch" / Jquery version / CDN and "without patch" / Jquery version / CDN to no avail. Help is very appreciated...

Thanks

realobiwankenobi’s picture

Hello, patch #10 is working, but try to avoid to hack the drupal core, so implement a hook in your module (this code should work with the latest 7.33) Drupal:

/**
 * Implements hook_block_view_alter()
 */
function yourmodule_block_view_alter(&$data, $block) {
  $block_id = $block->module.'--'.$block->delta;
  switch ($block_id) {
    case 'accordion_menu--1':
      $js = "jQuery(function() {";
      $js .= "jQuery('.accordion-menu-wrapper .accordion-header.no-children').each(function(index, element) {
            jQuery(this).unbind();
          });";
      $js .= "});";
      drupal_add_js($js, array('type' => 'inline', 'scope' => 'footer', 'group' => JS_DEFAULT, 'weight' => 100));
      break;
  }
}
bgarner’s picture

#14 works a treat. Cheers realobiwankenobi.

Nice solution and doesn't involve hacking modules !!

volker23’s picture

Thx realobiwankenobi, i tried this with a helper module and your snippet on a vanilla drupal 7.33, the latest dev of accordion-menu and jQuery-Update set to 1.7 (tested all cdn's and also without).
The menu-item without children still expands (on page load), though the animation for these items is gone (i guess this is what the "unbind" is doing).

Any other tips? Thanks a lot!

vvs’s picture

If doing this with patch and CSS?

.accordion-header.no-children + .ui-accordion-content {
  display: none !important;
}

For me it helped.

codechefmarc’s picture

#14 worked great for me too!

  • solotandem committed fb58086 on 7.x-1.x authored by Peacog
    Issue #1616300 by Peacog: Disable accordion effect on top-level menu...
solotandem’s picture

Status: Needs review » Fixed

Thanks for reporting this and supplying a patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.