创建新的jstree节点后如何设置ID?

我正在使用jsTree 1.0.并具有以下代码

$(document).ready(function () {
    $("#folders_tree").jstree({
        "core": {
            "initially_open": ["root"]
        },"html_data": {
            "data": '<?= $folders; ?>'
        },"themes": {
            "theme": "default","dots": true,"icons": true,"url": "<?= Yii::app()->request->baseUrl ?>/css/jstree/themes/default/style.css"
        },"contextmenu": {
            "items": {
                "create": {
                    "label": "Create","action": function (obj) {
                        this.create(obj);
                    },"_disabled": false,"_class": "add","separator_before": false,"separator_after": false,"icon": false
                },"rename": {
                    "label": "Rename","action": function (obj) {
                        this.rename(obj);
                    },"_class": "rename","remove": {
                    "label": "Delete","action": function (obj) {
                        this.remove(obj);
                    },"_class": "delete","separator_before": true,"ccp": false
            }
        },"plugins": ["themes","html_data","ui","crrm","contextmenu"]
    });

    /* Callbacks */

    var folders = $("#folders_tree");

    folders.bind("create.jstree",function (e,data) {
        var parent_id = data.rslt.parent[0].id;
        var name = data.rslt.name;
        var node = data.args[0];
        var dataArray = {
            "ref_folder": parent_id,"name": name
        };
        var dataString = JSON.stringify(dataArray);
        $.ajax({
            type: 'POST',url: '<?= Yii::app()->createUrl('
            ajax / createfolder ') ?>',data: {
                data: dataString
            },success: function (jdata) {
                var json_data = JSON.parse(jdata);
                // Here's! This code is not working. Id is not set.
                $(node).attr("id",json_data.new_id);
            },dataType: 'text'
        });
    });
});    
$(node).attr("id",json_data.new_id) // this code is not working.

我被困在这个:(如何设置此ID?

最佳答案
节点变量必须声明为:

var node = data.rslt.obj;

并称为:

node.attr("id",json_data.new_id);

相关文章

jQuery插件的种类 1、封装对象方法 这种插件是将对象方法封装起来,用于对通过选择器获取的jQuery对象进...
扩展jQuery插件和方法的作用是非常强大的,它可以节省大量开发时间。 入门 编写一个jQuery插件开始于给...
最近项目中需要实现3D图片层叠旋转木马切换的效果,于是用到了jquery.roundabout.js。 兼容性如图: ht...
一、什么是deferred对象? 开发网站的过程中,我们经常遇到某些耗时很长的javascript操作。其中,既有异...
AMD 模块 AMD(异步模块定义,Asynchronous Module Definition)格式总体的目标是为现在的开发者提供一...