Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cs-jqtree-contextmenu

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cs-jqtree-contextmenu

Provides a simple way to handle context menus with jqTree.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
decreased by-17.14%
Maintainers
1
Weekly downloads
 
Created
Source

jqTreeContextMenu

A context menu "plugin" to jqTree.

Heavily modifed version of the original.

Usage

Example:

    <!-- context menu -->
    <ul id="context-menu" class="dropdown-menu">
        <li data-item="edit"><a>Edit</a></li>
        <li data-item="delete"><a>Delete</a></li>
        <li data-item="foo"><a>bar</a></li>
    </ul>  

    <!-- jqTree -->
    <div id="tree"></div>

    <script>
      $(function() {
          var data = [
              {
                   name: 'node1', id: 1,
                   children: [
                       { name: 'child1', id: 2 },
                       { name: 'child2', id: 3 }
                   ]
              },
              {
                  name: 'node2', id: 4,
                  children: [
                      { name: 'child3', id: 5 }
                  ]
              }
          ];
          $('#tree').tree({ data: data });
          $('#tree').jqTreeContextMenu({
              menu: '#context-menu',
              onContextMenuItem: function(e, node, $el){
                  console.log($el.data("item"));
                  console.log(node.name);
              }
          });
      });
    </script>
</body>

Options

NameTypeDefaultDescription
menustringundefinedA jQuery selector for the menu (ie #context-menu)
selectClickedNodebooltrueWhether or not the jqTree node should be selected when right-clicked
onContextMenuItemclosurenullCalled when a context menu item is clicked. functon(e, node, $menuItem) { }
contextMenuDeciderclosurenullCalled before the menu is shown to allow choosing the context menu (see below)
menuFadeDurationint250The time in miliseconds for the menu fade in/out effect

Examples

contextMenuDecider

Use this closure option to decide which context menu should be shown when a node is clicked:

    $('#tree').jqTreeContextMenu({
        menu: '#context-menu',
        contextMenuDecider: function(node) {
            // Return a special context menu for the "root" jqTree node...
            if (!node.parent.parent) {
                return '#context-menu-root';
            }

            // Return false and the default context menu will be shown...
            return false;
        }
    });

onContextMenuItem

Use this closure to decide what action to take when a menu item is clicked. See the use example for more detail.

Events

NameParametersDescription
cm-jqtree.item.clickevent, node, $elThis is triggered when a menu item is clicked. The $el is the menu item itself

Keywords

FAQs

Package last updated on 08 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc