0

I have xml file displayed in jstree. I can select node with the following code:

selectNodeEvents = function (data) {
    var ready = false;
    $("#jstree").bind("reselect.jstree", function () {
        var selectedNode = $.cookies.get('mySelectedNode');
        jQuery("#jstree").jstree("select_node", selectedNode);
        ready = true;
    })
    .bind("select_node.jstree", function (event, data) {
        alert(data.inst.get_text(data.rslt.obj));

    })
}

I tried adding the jstree demo code for remove tree node but, I don't think I understand how to go about it. Can someone guide me how to go about this?

.bind("remove.jstree", function (e, data) {
    data.rslt.obj.each(function () {
        $.ajax({
            async: false,
            type: 'POST',
            url: "/static/v.1.0pre/_demo/server.php",
            data: {
                "operation": "remove_node",
                "id": this.id.replace("node_", "")
            },
            success: function (r) {
                if (!r.status) {
                    data.inst.refresh();
                }
            }
        });
    });
})
4

1 回答 1

0

这是我的功能(片段),也许这有帮助:

.bind("remove.jstree", function(e, data) {
    data.rslt.obj.each(function () {
        $.post(
            "/delete",
            {
                "id" : this.id.replace("phtml_","")
            },
            function (r) {
                if(!r.status) {
                    $.jstree.refresh(data.rlbk);
                }
            }
        );
    });
});
于 2013-09-06T07:19:16.833 回答