我的jstree脚本中的重命名节点不起作用,并且J不知道为什么,这是我的脚本:

$(function () {
 $("#stworz_powiazanie").click(function () {
 $("#pages-wrapper").jstree("create");
    });
$("#usun_powiazanie").click(function () {
    if(!confirm("Czy na pewno chcesz usunąć tę stronę?"))return;
    $("#pages-wrapper").jstree("remove");
});
$("#zmien_nazwe").click(function () {
   $("#pages-wrapper").jstree("rename");
});
$("#cut").click(function () {
    $("#pages-wrapper").jstree("cut");
});
$("#paste").click(function () {
    $("#pages-wrapper").jstree("paste");
});
$("#pages-wrapper").jstree({
 "core" : { "initially_open" : [ "root" ],
            "load_open" :true,
            "animation" :0,
 },
"html_data" : {
            "ajax" : {
            "url" : "./pobierz.php",
            "data" : function (n) {
                return { id : n.attr ? n.attr("id") : 0 };
            }
        }           },
    "plugins" : ["themes","html_data","ui","contextmenu","crrm","types"],
(............)

$("#pages-wrapper").bind("rename.jstree", function (e, data) {
        $.ajax({
                type: "POST",
                url: './server.php',
                 data: {
                "operation" : "rename_node",
                "id" : data.rslt.obj.attr("id").replace("node_",""),
                "title" : data.rslt.new_name
                },
                success : function (r) {
                    if(!r.status) {
                        data.inst.refresh();
                        alert('Zmieniono Nazwe');
                    }
                }
        });
    })
});
});


来自firebug J的报告:

TypeError:obj未定义
返回obj.nodeValue;

我的脚本有什么问题?谁能检查一下并告诉我出什么问题了?

最佳答案

替换以下行

"id" : data.rslt.obj.attr("id").replace("node_",""),


通过

"id" :  $(data.rslt.obj).attr("id").replace("node_",""),

07-24 09:38
查看更多