GithubHelp home page GithubHelp logo

jqtreecontextmenu's Introduction

jqTreeContextMenu

A context menu "plugin" to jqTree.

Demo

http://daviduv.github.io/jqTreeContextMenu/

Usage

Create a div that contains the menu. See the demo for an example how to do it using Bootstrap.

Use jqTree to create the tree. See documentation for jqTree on how to do this (or look in the demo).

When the tree is created you can do the following to set up the context menu:

$tree.jqTreeContextMenu(menu, callbacks);

menu is the jQuery object of the menu div. callbacks is a hash structure with following format:

{
	menuItem: action,
	menuItem: action
}

menuItem is the name of the menu item (this will be matched to what's inside the menu item href anchor attribute). action is a function that will handle the click on that menu item.

Example

$('tree').jqTreeContextMenu($('#myMenu'), {
    "edit": function (node) { alert('Edit node: ' + node.name); },
    "delete": function (node) { alert('Delete node: ' + node.name); },
    "add": function (node) { alert('Add node: ' + node.name); }
});

API

There is also a minimal API to enable/disable menu items.

// Get handle to API when initializing the menu.
var menuAPI = $('tree').jqTreeContextMenu(...);

// Disable all menu items
menuAPI.jqTreeContextMenu.disable()
// Disable all menu items of a certain kind. Here 'add' and 'delete'
// menu items are deleted.
menuAPI.jqTreeContextMenu.disable(['add', 'delete'])
// Disable menu items for a certain node in the tree.
menuAPI.jqTreeContextMenu.disable(nodeName, ['add', 'delete'])

// Enable all menu items
menuAPI.jqTreeContextMenu.enable()
// Enable all menu items of a certain kind. Here 'add' and 'delete'
// menu items are deleted.
menuAPI.jqTreeContextMenu.enable(['add', 'delete'])
// Enable menu items for a certain node in the tree.
menuAPI.jqTreeContextMenu.enable(nodeName, ['add', 'delete'])

For a complete example of usage, see the demo at http://daviduv.github.io/jqTreeContextMenu/.

jqtreecontextmenu's People

Contributors

daviduv avatar

Watchers

Navid Nikpour avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.