Get started with nestable2 CDN

MIT licensed

Nestable2 is a jQuery plugin that allows lists to be nested and reordered dynamically.

Tags:
  • tree
  • list
  • sortable
  • nestable
  • nestable2
  • drag
  • drop

Stable version

Copied!

How to start using nestable2 CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with nestable2 CDN - cdnhub.io</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0-alpha1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nestable2@1.6.0/css/nestable.min.css">
</head>
<body>
    <div class="container mt-5">
        <button class="btn btn-primary mb-3" id="toggle-button">Toggle Nestable</button>
        <div id="nestable"></div>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.cdnhub.io/nestable2/1.6.0/jquery.nestable.min.js"></script>
    <script>
        $(document).ready(function() {
            $('#toggle-button').click(function() {
                $('#nestable').toggleClass('list-nested');
                if ($('#nestable').hasClass('list-nested')) {
                    $('#nestable').nestable({
                        maxDepth: 3,
                        expandPath: function(list, item) {
                            return false;
                        },
                        itemOpenFunction: function(item) {
                            this.expandPath(item.parentNode, item);
                        },
                        itemCloseFunction: function(item) {
                            this.collapsePath(item.parentNode, item);
                        }
                    });
                } else {
                    $('#nestable').nestable('destroy');
                }
            });
        });
    </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!

All versions