nils-soderman / ctxmenu-javascript Goto Github PK
View Code? Open in Web Editor NEWA free JavaScript plugin to create custom right click context menus.
Home Page: https://nilssoderman.com/code/ctxmenu
License: MIT License
A free JavaScript plugin to create custom right click context menus.
Home Page: https://nilssoderman.com/code/ctxmenu
License: MIT License
Please correct me if I'm wrong, but the documentation mentions no way get the element that was clicked on. There is, however, a way to get it.
contextMenu.addItem("alertElement", function () {
alert(contextMenu._elementClicked)
});
I assume the _elementClicked
variable is not supposed to be accessed, as it's marked as private. Still, I thought it could be worth mentioning!
Hi,
Is there a method to call the context menu i created in desired event ..
the scenario is i do something after left click event and i want to invoke the context menu directly when the code on-click finish
so, is there a method to do this .......
Thanks for sharing information
It looks like the _ctxMenusHas function needs tweaked to accommodate SVG images returning something besides the class names. Here's what I tried to fix the issue.
if (element.className != undefined && element.hasAttribute("class")){ //Added this second condition
//const classNames = element.className.split(" "); //Original that seemed to be broken with SVGs
const classNames = element.getAttribute("class").split(" ");
for(var i = 0; i < classNames.length; i++) {
if(this._ctxMenus.has("."+classNames[i])){
return this._ctxMenus.get("."+classNames[i]);
}
}
}
Hi, I'm having problems with the addSeparator function.
I haven't modified the script or anything else that caused it to fail
here is the code:
var contextMenu = CtxMenu();
contextMenu.addItem("Clear Advanced Of The Advanced" , icon = "Assets\favicon.ico");
contextMenu.addItem("Options" , icon = "Assets\favicon.ico");
contextMenu.addSeparator();
contextMenu.addItem("Exit" , icon = "Assets\favicon.ico");
it says the function is invalid
what is bad?
Hi,
I am considering using your contextmenu solution.
On my page, I have multiple list widgets in which I can select items.
I want a context menu for each list widget.
Can I use your solution and if so do you a suggestion how to apply it?
thanks.
There is a typo in API.
-addSeperator
+addSeparator
For some cases i must remove some items from menu and add new ones. As i see in your code, there is a removeItem property. How can i use it? For example what is the usage of removeItem if i want to remove the first item from the menu?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.