Sha256: c6ca3b9f094500f83a16ccd1f1732f488313f5dbad5d5ac8e7c8f78525b5909c

Contents?: true

Size: 933 Bytes

Versions: 7

Compression:

Stored size: 933 Bytes

Contents

$(function() {
    var $tree = $('#tree1');

    $tree.tree({
        data: ExampleData.example_data,
        autoOpen: 1,
        onCreateLi: function(node, $li) {
            // Append a link to the jqtree-element div.
            // The link has an url '#node-[id]' and a data property 'node-id'.
            $li.find('.jqtree-element').append(
                '<a href="#node-'+ node.id +'" class="edit" data-node-id="'+ node.id +'">edit</a>'
            );
        }
    });

    // Handle a click on the edit link
    $tree.on(
        'click', '.edit',
        function(e) {
            // Get the id from the 'node-id' data property
            var node_id = $(e.target).data('node-id');

            // Get the node from the tree
            var node = $tree.tree('getNodeById', node_id);

            if (node) {
                // Display the node name
                alert(node.name);
            }
        }
    );
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iqvoc-4.12.1 vendor/assets/bower_components/jqtree/static/examples/custom_html.js
iqvoc-4.12.0 vendor/assets/bower_components/jqtree/static/examples/custom_html.js
iqvoc-4.11.1 vendor/assets/bower_components/jqtree/static/examples/custom_html.js
iqvoc-4.11.0 vendor/assets/bower_components/jqtree/static/examples/custom_html.js
iqvoc-4.10.0 vendor/assets/bower_components/jqtree/static/examples/custom_html.js
iqvoc-4.9.0 vendor/assets/bower_components/jqtree/static/examples/custom_html.js
iqvoc-4.8.2 vendor/assets/bower_components/jqtree/static/examples/custom_html.js