I'm trying to disable sliding submenus in my mobile menu by adding the following code to a js file that I implemented in my theme:

jQuery(document).ready(function( $ ) {
      $("#off-canvas").mmenu({
         "slidingSubmenus": false
      });
   });

Unfortunately it has no effect. What am I doing wrong?

Comments

johnnny83 created an issue. See original summary.

tanc’s picture

Version: 8.x-2.4 » 8.x-2.x-dev
Assigned: Unassigned » tanc
Category: Support request » Feature request

As it stands now the options are hard coded in responsive_menu.js. You can get the mmenu object and modify it with something like this
var mmenu = $('#off-canvas').data('mmenu'); but I don't think you can change the initial options once the mmenu is instantiated. Your code would only work if creating a new instance of mmenu.

One solution would be to add an option in the module UI to reflect that mmenu option you want to modify. That's already happening for the position and theme, so it wouldn't be too much trouble to add for the slidingSubmenus option. I'll turn this into a feature request.

johnnny83’s picture

Hm, it doesn't work, but my JavaScript knowledge is also not the best (shame on me).

I don't want to patch modules, so I'll have to wait till it is implemented. It wouldn't be a bad idea to also add all the other possible options, so you can fully profit from the library. It would also be interesting to change it to on-canvas.

ConradFlashback’s picture

It's easy. The file isn't responsive_menu.js but responsive_menu.config.js in js folder.

Line 25 from
extensions: [theme, 'effect-slide-menu'],
to
extensions: [theme, 'effect-slide-menu','fullscreen','iconbar','effect-menu-zoom','popup'],

There is the updating modules big problem with this solution.
A simple text field in admin with variables cut and paste would be great.
A completely fieldable structure with all extensions/options would be perfect ;)

Bye.

tanc’s picture

Patches are welcome!

kunalkursija’s picture

Assigned: tanc » kunalkursija

@tanc: I am working on this patch.

kunalkursija’s picture

Assigned: kunalkursija » Unassigned
Status: Active » Needs review
StatusFileSize
new4.39 KB
new12.04 KB

I have added a screenshot of updated UI option.

Adding Patch.

kunalkursija’s picture

Hi @tanc,

I have noticed that the zposition property is also hard-coded and 'mmenu' provides some position configurations too.

I will work on the functionality and combine the below functionalities in a single patch:

  • Enable/Disable sliding sub menus
  • zposition Configuration

Reference: http://mmenu.frebsite.nl/documentation/extensions/positioning.html

Thanks,

tanc’s picture

Great work so far! :)

Will review properly once you've completed the next part.

kunalkursija’s picture

StatusFileSize
new51.06 KB
new5.34 KB

@tanc - Adding patch for the below functionalities:

  1. Enable/Disable sliding sub menus
  2. zposition Configurations

Please review and let me know if you find any issues.

Welcome:) By the way, this is one nice module to have on a site!

Thanks,

steve.colson’s picture

Status: Needs review » Needs work

Patch no longer cleanly applies to 8.x-2.6

tanc’s picture

There is an interesting patch in this issue #2955215: Allow extension/override of mmenu settings. I like the approach of that issue as it keeps this module from trying to cover all possible options and instead allows an advanced themer to introduce their own overrides.

tanc’s picture

tanc’s picture

Status: Needs work » Closed (won't fix)

Closing this as there will be a solution in the 8.x-3.x branch when released.