基于Bootstrap的jQuery右键上下文菜单插件 A Context menu plugin using Bootstrap's style

Basic demos

Demo 1

On instantiation, the context menu is given a selector of elements where it will be triggered.

在这个例子中,在下面的矩形区域内右键点击就可以打开上下文菜单。

在这个区域内的任何位置点击右键

查看代码

Demo 2

你也可以通过不同的事件来触发上下文菜单,也可以将右键菜单放置在触发元素的任何相对位置。

View the code

高级示例

Demo 3

onClick事件监听器可以知道一组元素中的哪一个被点击了。

# Name Description
1 First row Lorem ipsum dolor sit amet
2 Second row Nemo enim ipsam voluptatem quia voluptas
3 Third row Ut enim ad minima veniam

View the code

Demo 4

你可以给每一个action一个ID和通过actionsGroups参数对它们进行分组。你也可以通过isShownisEnabled参数来控制菜单项是否显示或是否可用。

可以通过iconClass属性来使用Font Awesome字体图标。

# Name Description
1 First row Lorem ipsum dolor sit amet
2 Second row Nemo enim ipsam voluptatem quia voluptas Not editable
3 Third row Ut enim ad minima veniam Not deletable

View the code

Demo 5

Classes can also be added easily to an action by setting a classNames property, which will be parsed through the classnames utility. This property can be a string, an object or a function that receives the element's fetched data as a first argument.

In the same way, an action's name can be defined as a function. In that case, it will be called before each render of the menu, receiving as the first argument the data returned by fetchElementData.

# Name Description
1 John Martin Lorem ipsum dolor sit amet
2 Peter Roberts Nemo enim ipsam voluptatem quia voluptas
3 Stuart Smith Ut enim ad minima veniam Not editable

View the code