Anuya
Anuya

Reputation: 8350

How to get the New Name of node changed in JSTree "rename"

I am trying to rename the node using the below code, I need to pass the ID and New Name of node to server.aspx

How can i get the new name of node

How can i pass these two values to server.aspx page

Thanks

   .bind("rename.jstree", function (e, data) {
            data.rslt.obj.each(function () {
                $.ajax({
                    async: false,
                    type: 'POST',
                    url: "./ajax/server.aspx",
                    data: 
                    {
                        "operation": "rename_node",
                        "id": this.id 
                    },
                    success: function (r) {
                        if (r == "-1") {
                            $.jstree.rollback(data.rlbk);
                        }
                        else {
                            $(data.rslt.oc).attr("id", "node_" + r.id);
                            if (data.rslt.cy && $(data.rslt.oc).children("UL").length) {
                                data.inst.refresh(data.inst._get_parent(data.rslt.oc));
                            }
                        }
                    }       
                });
            });
        })

Upvotes: 0

Views: 1057

Answers (1)

Anuya
Anuya

Reputation: 8350

  .bind("rename.jstree", function (e, data) {
        data.rslt.obj.each(function () {
            $.ajax({
                async: false,
                type: 'GET',
                url: "./ajax/server.aspx",
                data: 
                {
                    "operation": "rename",
                    "id": this.id,
                    "new_name" : data.rslt.new_name 
                },
                success: function (r) {
                    if (r == "-1") {
                        $.jstree.rollback(data.rlbk);
                    }
                    else {
                        $(data.rslt.oc).attr("id", "node_" + r.id);
                        if (data.rslt.cy && $(data.rslt.oc).children("UL").length) {
                            data.inst.refresh(data.inst._get_parent(data.rslt.oc));
                        }
                    }
                }       
            });
        });

    })

Upvotes: 2

Related Questions