Comments (4)
Bootstrap 3.0 has removed the ability to support submenus, but it is possible to position Bootstrap 2.3.2 submenus correctly with this context menu plugin by adding the following code:
In ContextMenu.prototype.show
:
$menu.on('mouseover.context.data-api', items, $.proxy(this.layoutSubmenu, this))
In ContextMenu.prototype.closemenu
:
$menu.off('mouseover.context.data-api', items, $.proxy(this.layoutSubmenu, this))
Then add the method:
,layoutSubmenu: function (e) {
var parent = $(e.currentTarget);
if (!parent.is('.dropdown-submenu') || parent.is('.dropdown-submenu-positioned')) {
return;
}
parent.removeClass("pull-left dropup");
var child = parent.children('.dropdown-menu');
var childOffset = child.offset();
if (childOffset.left + child.outerWidth() > $(window).width()) {
parent.addClass("pull-left");
}
if (childOffset.top + child.outerHeight() > $(window).height()) {
parent.addClass("dropup");
}
parent.addClass('dropdown-submenu-positioned');
}
Note that with this solution, the CSS rule for .dropup. dropdown-submenu > .dropdown-menu
must be changed to .dropup.dropdown-submenu > .dropdown-menu
:
// Dropups
.dropup.dropdown-submenu > .dropdown-menu {
top: auto;
bottom: 0;
margin-top: 0;
margin-bottom: -2px;
.border-radius(5px 5px 5px 0);
}
Since it's deprecated in Bootstrap I decided just to leave a comment here for anyone who (like me) really wanted this functionality regardless of whether Bootstrap thinks it's a good idea. I can submit a pull request if you like though!
from bootstrap-contextmenu.
This is something I'll have to do in the next version.
from bootstrap-contextmenu.
I noticed bootstrap's dropdown does not automatically adjust submenu position when close on borders. Is this something that should be added to the contextmenu?
from bootstrap-contextmenu.
I was able to handle sub-contextmenus by calling .menu() on the context menu before initializing the plugin.
ie:
$("#context-menu").menu();
$("#container").contextmenu({
"target" : "#context-menu",
"onItem" : handleContextMenu
});
from bootstrap-contextmenu.
Related Issues (20)
- Q: Are you moving this to a new maintainer?
- errors occur when it is in summernote' table
- Adding context menu to Raphael/SVG
- why tr is remove???
- Bootstrap Modal not working in ContextMenu
- How can i change actions dynamicaly
- sydcanem.com domain with demo has expired ... HOT 1
- bootstrap-contextmenu Get the right-click content
- [Tips] Adaption for bootstrap v4+
- onItem will be called twice when triggers a submenu item HOT 2
- Calling closemenu() without argument causes type error HOT 6
- Add to npmjs.com
- can't nest other controls that require click inside menu (e.g. form elements)
- Safari on OSX HOT 4
- How to bind "onItem" ? HOT 1
- bug:Uncaught TypeError: Cannot read property 'stopPropagation' of undefined HOT 8
- Cannot read property 'left' of undefined HOT 2
- After open, 2nd right click open a real context menu HOT 2
- Popup position is incorrect
- Uncaught TypeError: Cannot read property 'stopPropagation' of undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bootstrap-contextmenu.