bootstrap-menu icon indicating copy to clipboard operation
bootstrap-menu copied to clipboard

How about adding support of nested menus?

Open KenZZ107 opened this issue 8 years ago • 12 comments

Would it support nested menus(submenus) by options like

{
   actions: [{
      name: 'have some sub Actions',
      actions: [{
         name: 'I am a sub item', 
         onClick: function() {...}
      }]
   },
   ...
   ]
}

?

KenZZ107 avatar Jan 07 '17 03:01 KenZZ107

Sub-menu on hover/click will be remarkable.

Nabid avatar Jun 15 '17 07:06 Nabid

I'm working on a PR for this. Will hopefully get it finished this weekend

schmoove avatar Jun 16 '17 19:06 schmoove

Ok here is my fork which offers submenu support:

https://github.com/schmoove/bootstrap-menu/tree/master/dist

I have refactored it somewhat, replacing "actions" with "menuItems" (which I feel is more consistent with the new functionality and existing options), and removing actionGroups in favor of adding the divider to the "menuItems" object. Bootstrap 3 doesn't support submenus by default, so you will need to include the new BootstrapMenu.css file if you are using Bootstrap 3+

Here's a demo showing how the new "menuItems" option replaces "actions":

https://github.com/schmoove/bootstrap-menu/blob/master/docs/submenu-demo.html

I've only modified the dist files for now - let me know what you think of these changes, and I can update the src files for a possible PR to the original repo.

schmoove avatar Jun 18 '17 16:06 schmoove

Hello, have tried your fork (from dist-folder), it works. but it seems it needs some logic about positioning nested submenus. screenshot: https://drive.google.com/open?id=0B7YxJcgXibf5OTRQT3FvckRNOHc . so each submenu (on some rendering-point) should analyze will it have enough space for showing.. if not it should be rendered (in some magic way) into another direction. what do you think? thanks

lon9man avatar Aug 23 '17 12:08 lon9man

Yes that's a good idea - I'll work on an update for it.

On 23 August 2017 at 05:18, lon9man [email protected] wrote:

Hello, have tried your fork (from dist-folder), it works. but it seems it needs some logic about positioning nested submenus. screenshot: https://drive.google.com/open?id=0B7YxJcgXibf5OTRQT3FvckRNOHc . so each submenu (on some rendering-point) should analyze will it have enough space for showing.. if not it should be rendered (in some magic way) into another direction. what do you think? thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dgoguerra/bootstrap-menu/issues/11#issuecomment-324311285, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQqRcpTEsacocr61WMR8AnGUs8nKCf3ks5sbBh-gaJpZM4LdUfQ .

schmoove avatar Aug 23 '17 16:08 schmoove

also can be useful (as option) adding title-attribute into menuitem-DOM, which by default in browsers shows as tooltip. possible use case: short explaining of the meaning for the strange:) text of the menuitem. screen: https://drive.google.com/open?id=0B7YxJcgXibf5NVV2cjhiaWFSVzA

lon9man avatar Aug 25 '17 14:08 lon9man

Ok I've added force-left support for submenus if there is no space to the right.

If everything checks out I can open a PR if the @dgoguerra is interested in supporting this

schmoove avatar Sep 06 '17 20:09 schmoove

@schmoove have tried, works as expected! screenshot: https://drive.google.com/open?id=0B7YxJcgXibf5RExGNWc0Ul9hN2M what do you think about my last message related to the title-attribute (https://github.com/dgoguerra/bootstrap-menu/issues/11#issuecomment-324940634) ? thanks for your time

lon9man avatar Sep 07 '17 13:09 lon9man

Ok all set, and pushed to my repo

image

schmoove avatar Sep 07 '17 19:09 schmoove

@schmoove ooh, it is made my day) your changes are very helpful, will check it with my sources! big thanks

lon9man avatar Sep 08 '17 09:09 lon9man

@schmoove, it looks like a bug.

What i am doing i am trying to use isEnabled-method, which dynamically must Disable/Enable menuitem. https://jsfiddle.net/longman/d33ptjzy/ (your js is fully inserted into Javascript-window, my js is there at the bottom)

What i got when menuitem was ONCE disabled then it NEVER can be enabled. it looks like wrong logic, which manipulates with css-classes.

FYI: i have investigated sources in BootstrapMenu.prototype.open-method. Maybe problem in: you got classes from DOM-element (in my case when menuitem disabled, it has 'disabled'-class)

baseClasses = $menuItem.attr('class')
...
var outputClasses = classNames(baseClasses,customClasses);
...
$menuItem.attr('class', outputClasses);

but dgoguerra got it only from options and doesn't use classes from DOM-element:

var action = _this.options.actions[actionId];
var classes = action.classNames || null;
...
$action.attr('class', classNames(classes || ''));

What i expect it should Disable/Enable menuitem strictly to the result of isEnabled-method. correctly workable example based on dgoguerra-sources: https://jsfiddle.net/longman/jzfxx004/2/

lon9man avatar Sep 21 '17 13:09 lon9man

Ok all set, and pushed to my repo

FYI, seems to be a bug with this fork where a divider immediately following a menuItem with subMenuItems will not render.

dmkallan avatar Feb 22 '19 05:02 dmkallan