Hey all!
Thought I’d just post about an update to jchristman:context-menu, which I’ve rewritten from a simple DOM manipulating wrapper for another library into a true, meteor package (live example here). It utilizes a chainable, programatic menu construction syntax, simple template-driven menu model, and a very easy attaching syntax. I think this package makes it extremely easy to get at the right-click functionality without having to put very much effort into hooking into .onRendered functions. An example:
// Define a menu. This should go in a Meteor.startup on the client
let exampleMenu5 = (new Context.Menu('example5'))
.addHeader('Example 5')
.addItem('9', function (context, element) { alert('9 clicked on ' + context.target.id) })
Context.addMenu(exampleMenu5);
<!-- This will attach the above menu to your element -->
<li class='someClass' {{Context.attach 'example5'}}></li>
It’s that easy! Some additional features include:
- Automatic positioning based on where you right-click (keeps things from going offscreen)
- Automatic combining of menus if there are menus “behind” the thing you clicked on (bubbling events)
- Attaching multiple menus to the same item that will combine
This is my first release with the new syntax, so there are some things that need to be smoothed out, but I think it’s mostly ready for use. Let me know what you think!