• This repository has been archived on 13/Jan/2020
  • Stars
    star
    2,473
  • Rank 18,586 (Top 0.4 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Drag & drop hierarchical list with mouse and touch compatibility (jQuery plugin)

Nestable

PLEASE NOTE

I cannot provide any support or guidance beyond this README. If this code helps you that's great but I have no plans to develop Nestable beyond this demo (it's not a final product and has limited functionality). I cannot reply to any requests for help.


Drag & drop hierarchical list with mouse and touch compatibility (jQuery / Zepto plugin)

Try Nestable Demo

Nestable is an experimental example and not under active development. If it suits your requirements feel free to expand upon it!

Usage

Write your nested HTML lists like so:

<div class="dd">
    <ol class="dd-list">
        <li class="dd-item" data-id="1">
            <div class="dd-handle">Item 1</div>
        </li>
        <li class="dd-item" data-id="2">
            <div class="dd-handle">Item 2</div>
        </li>
        <li class="dd-item" data-id="3">
            <div class="dd-handle">Item 3</div>
            <ol class="dd-list">
                <li class="dd-item" data-id="4">
                    <div class="dd-handle">Item 4</div>
                </li>
                <li class="dd-item" data-id="5">
                    <div class="dd-handle">Item 5</div>
                </li>
            </ol>
        </li>
    </ol>
</div>

Then activate with jQuery like so:

$('.dd').nestable({ /* config options */ });

Events

The change event is fired when items are reordered.

$('.dd').on('change', function() {
    /* on change event */
});

Methods

You can get a serialised object with all data-* attributes for each item.

$('.dd').nestable('serialize');

The serialised JSON for the example above would be:

[{"id":1},{"id":2},{"id":3,"children":[{"id":4},{"id":5}]}]

Configuration

You can change the follow options:

  • maxDepth number of levels an item can be nested (default 5)
  • group group ID to allow dragging between lists (default 0)

These advanced config options are also available:

  • listNodeName The HTML element to create for lists (default 'ol')
  • itemNodeName The HTML element to create for list items (default 'li')
  • rootClass The class of the root element .nestable() was used on (default 'dd')
  • listClass The class of all list elements (default 'dd-list')
  • itemClass The class of all list item elements (default 'dd-item')
  • dragClass The class applied to the list element that is being dragged (default 'dd-dragel')
  • handleClass The class of the content element inside each list item (default 'dd-handle')
  • collapsedClass The class applied to lists that have been collapsed (default 'dd-collapsed')
  • placeClass The class of the placeholder element (default 'dd-placeholder')
  • emptyClass The class used for empty list placeholder elements (default 'dd-empty')
  • expandBtnHTML The HTML text used to generate a list item expand button (default '<button data-action="expand">Expand></button>')
  • collapseBtnHTML The HTML text used to generate a list item collapse button (default '<button data-action="collapse">Collapse</button>')

Inspect the Nestable Demo for guidance.

Change Log

15th October 2012

  • Merge for Zepto.js support
  • Merge fix for remove/detach items

27th June 2012

  • Added maxDepth option (default to 5)
  • Added empty placeholder
  • Updated CSS class structure with options for listClass and itemClass.
  • Fixed to allow drag and drop between multiple Nestable instances (off by default).
  • Added group option to enabled the above.

Author: David Bushell http://dbushell.com @dbushell

Copyright ยฉ 2012 David Bushell | BSD & MIT license

More Repositories

1

Responsive-Off-Canvas-Menu

A responsive off-canvas menu using CSS transforms and transitions. This repository contains several demos to support a Smashing Magazine article.
HTML
822
star
2

grunt-svg2png

Grunt plugin to rasterize SVG to PNG images using PhantomJS
JavaScript
76
star
3

dbushell-Origin

My front-end development starter kit with automated build tasks.
CSS
64
star
4

sveltekit-adapter-deno

๐Ÿฆ• SvelteKit Adapter for Deno and Deno Deploy
TypeScript
49
star
5

granary

๐ŸŒพ Git Large File Storage (LFS) server implementation written in TypeScript (sorry)
TypeScript
39
star
6

rpi-gpio-epaper

Control e-paper modules on the Raspberry Pi GPIO with Node.js
JavaScript
34
star
7

Pageshift

Ever wanted to add Powerpoint-esque transitions to your website? No? ...well you can now!
JavaScript
20
star
8

xml-streamify

Fetch and parse XML with JavaScript web streams and async iterators โœจ
TypeScript
19
star
9

dbushell-grunt-mustatic

Grunt task for rendering static HTML with Mustache templates
JavaScript
15
star
10

dinossr

๐Ÿฆ• A minimal web framework
TypeScript
13
star
11

dbushell-gutenberg-example

WordPress Gutenberg example blocks #wordpress #react
JavaScript
11
star
12

deno_streamdeck

๐Ÿฆ• Deno library for Stream Deck
TypeScript
8
star
13

docker-ubuntu

๐Ÿณ A configured Ubuntu sandbox development container
Dockerfile
8
star
14

jsonlike

๐Ÿ‹โ€๐ŸŸฉ Just enough JavaScript object validation
TypeScript
8
star
15

docker-traefik

๐Ÿ Use Traefik to proxy Docker containers for *.localhost development.
Shell
7
star
16

sveltekit-auth

SvelteKit app with GitHub OAuth login
TypeScript
7
star
17

sauroPod

๐ŸŽง Self-hosted podcast and audiobook media server and web app
TypeScript
6
star
18

velocirouter

A minimal async Request โ†’ Response router powered by URL Pattern API magic โœจ
TypeScript
6
star
19

muteswan

๐Ÿฆข Mute Swan is a short-term daily planner for todos and memos.
JavaScript
5
star
20

docker-wordpress-scripts

๐Ÿค– DWS is a small set of scripts to manage WordPress containers in Docker.
JavaScript
5
star
21

meSonic2

๐ŸŽง meSonicยฒ is an experimental media server and web client
TypeScript
5
star
22

Netlify-URL-Shortener

URL Unshortener (PWA deployed on Netlify)
JavaScript
4
star
23

audio-duration

๐Ÿ”Š Deno native audio duration for MP3 / M4A / M4B (no dependencies)
TypeScript
4
star
24

dbushell.com-old

David Bushell Website Design and Front-end Development
CSS
3
star
25

mesonic

๐ŸŽง meSonic is an experimental media server and web client partially compatible with the Subsonic API
JavaScript
3
star
26

dbushell.com

David Bushell โ€“ Freelance Web Design (UK)
TypeScript
3
star
27

dotfiles

Stuff for ~/
Vim Script
2
star
28

deno_usbhidapi

๐Ÿฆ• Deno FFI bindings for the HIDAPI library to access USB devices.
TypeScript
2
star
29

docker-xfce-vnc

An XFCE desktop environment and VNC server for remote access. Built upon a configured Ubuntu base image. Designed from browser testing.
Shell
2
star
30

carriageway

๐Ÿฆฅ Run async functions with limited concurrency and optional rate limiting
TypeScript
2
star
31

dbushell-origin2

My (new) front-end development starter kit with automated build tasks.
JavaScript
2
star
32

deno_turtle

๐Ÿข Streams random binary data at incredibly slow speeds!
JavaScript
1
star
33

designheroes.dbushell.com

ARCHIVE - Design Heroes was a link blog I ran between 2009 and 2012
HTML
1
star
34

diplodocache

(RETIRED) ๐Ÿ’พ Experimental fetch cache for Deno
TypeScript
1
star
35

cottoncoder.com

โ˜๏ธ The curated bookmark blog of web dev curiosities
Svelte
1
star