0

I Found one example of js tree in jquery ? in this user can add new data inside after selecting the the row. here http://jsfiddle.net/fuu94/

But When I remove all row (remove ul and li from mark up)and start making from first it will not work why ?

http://jsfiddle.net/fuu94/1/

$('#tree').jstree({
    "core": {
        "check_callback": true
    },
    "plugins": ["dnd"]
});

$('button').click(function () {
    var ref = $('#tree').jstree(true),
        sel = ref.get_selected();
    if (!sel.length) {
        return false;
    }
    sel = sel[0];
    sel = ref.create_node(sel);
    if (sel) {
        ref.edit(sel);
    }

});

1 Answer 1

1

According to the jstree documentation

"The minimal required markup is a < ul > node with some nested < li > nodes with some text inside."

-> http://www.jstree.com/docs/html/

As long as you make the menu using UL and LI it should do the rest for you (as in creating the tree).

So basically, if you remove the text from the LI and UL nodes and make your own text, duplicate the structure, you could make something like this:

-> http://jsfiddle.net/fuu94/3/

but the minimum requirements is something like:

<ul>
    <li></li>
</ul>

and if you want to use a submenu, add one of these :

    <li> Title Here
        <ul>
            <li></li>
            <li></li>
        </ul>
    </li>
Sign up to request clarification or add additional context in comments.

1 Comment

can you add element using add button first element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.