【问题标题】:Jstree and renameJstree 和重命名
【发布时间】:2012-10-29 13:43:24
【问题描述】:

在我的 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;

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

【问题讨论】:

    标签: jquery jstree


    【解决方案1】:

    替换下一行

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

    通过

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-10
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多