jquery-ui-contextmenu

jQuery plugin that turns a jQueryUI menu widget into a context menu.

Github星跟踪图

jquery.ui-contextmenu

GitHub version
Build Status
Selenium Test Status
npm
jsDelivr,

A jQuery plugin that provides a context menu (based on the standard jQueryUI menu widget).

  • Define menus from <ul> element or definition list (i.e.
    [{title: "Paste", cmd: "paste"}, ...]).
  • Themable using jQuery ThemeRoller.
  • Supports delegation (i.e. can be bound to elements that don't exist at the
    time the context menu is initialized).
  • Optional support for touch devices.

Status

The latest release is available at npm Registry:

$ npm install ui-contextmenu

GitHub version
See also the Change Log.

Demo

Live demo page:
sample

See also the unit tests and live examples

More:

Getting Started

First, include dependencies:

  • jQuery 1.7+ (3.x or later recommended)
  • jQuery UI 1.9+ (at least core, widget, menu), 1.12+ recommended
  • One of the ThemeRoller CSS themes or a custom one
  • jquery.ui-contextmenu.js (also available as CDN on
    ,
    cdnjs, or
    UNPKG)

for example

<head>
    <link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
    <script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    <script src="assets/jquery.ui-contextmenu.min.js"></script>

Assume we have some HTML elements that we want to attach a popup menu to:

<div id="container">
    <div class="hasmenu">AAA</div>
    <div class="hasmenu">BBB</div>
    <div class="hasmenu">CCC</div>
</div>

Now we can enable a context menu like so:

$("#container").contextmenu({
	delegate: ".hasmenu",
	menu: [
		{title: "Copy", cmd: "copy", uiIcon: "ui-icon-copy"},
		{title: "----"},
		{title: "More", children: [
			{title: "Sub 1", cmd: "sub1"},
			{title: "Sub 2", cmd: "sub1"}
			]}
		],
	select: function(event, ui) {
		alert("select " + ui.cmd + " on " + ui.target.text());
	}
});

Alternatively we can

initialize the menu from embedded <ul> markup.

For more information:

Credits

Thanks to all contributors.

Browser Status Matrix

Selenium Test Status

主要指标

概览
名称与所有者mar10/jquery-ui-contextmenu
主编程语言JavaScript
编程语言CoffeeScript (语言数: 5)
平台
许可证Other
所有者活动
创建于2013-03-09 13:21:40
推送于2020-03-14 16:38:01
最后一次提交2020-03-14 17:38:00
发布数32
最新版本名称v1.18.1 (发布于 2017-08-28 08:23:56)
第一版名称0.2.0 (发布于 2013-05-10 16:52:33)
用户参与
星数179
关注者数21
派生数79
提交数351
已启用问题?
问题数129
打开的问题数0
拉请求数9
打开的拉请求数0
关闭的拉请求数4
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?