鍍金池/ 問(wèn)答/HTML/ jsTree 保存與初始化

jsTree 保存與初始化

圖片描述

  $('#jurisdictionBox').jstree({
          "plugins" : ["checkbox","types","themes"], 
          "types": {
          "default" : {
            "icon" : false  // 關(guān)閉默認(rèn)圖標(biāo)
          },
        },
        'core': {
            'data': [
                  {
                    'text': '投融寶',
                    'state': {
                        'opened': true
                    },
                    'children': [
                            {
                                'text': '投洽峰會(huì)管理',
                                'state': {
                                    'opened': true
                                }
                            },
                            {
                                'text': '項(xiàng)目管理',
                                'children': [
                                    {
                                        'text': '項(xiàng)目聯(lián)營(yíng)',
                                        'icon': 'none'
                                   },
                                    {
                                        'text': '咨詢用戶',
                                        'icon': 'none'
                                    },
                                    {
                                        'text': '項(xiàng)目征集',
                                        'icon': 'none'
                                    }
                                ],
                                'state': {
                                    'opened': true
                                }
                           },
                            {
                                'text': '企業(yè)直播',
                                'state': {
                                    'opened': true
                                }
                           }
                    ]
                }
            ]
        }
    });
    var nodes  = $('#jurisdictionBox').jstree('get_checked');
    var ref = $('#jurisdictionBox').jstree(true);//獲得整個(gè)樹(shù)
    var sel = ref.get_selected(true); //獲得所有選中節(jié)點(diǎn),返回值為數(shù)組
   console.log(sel);
    這里取到的數(shù)組是這樣的:

{id: "j1_2", text: "投洽峰會(huì)管理", icon: false, parent: "j1_1", parents: Array(2), …}

{id: "j1_5", text: "咨詢用戶", icon: "none", parent: "j1_3", parents: Array(3), …}

{id: "j1_7", text: "企業(yè)直播", icon: false, parent: "j1_1", parents: Array(2), …}

現(xiàn)在的jsTree已經(jīng)用本地的data數(shù)據(jù)初始化完畢了,當(dāng)我們選擇其中某些項(xiàng)時(shí),應(yīng)該怎樣保存選中的數(shù)據(jù),保存成什么樣子的格式才能再一次初始化的時(shí)候保持上一次保存的狀態(tài)呢

回答
編輯回答
莓森

全部保存。。。

2017年3月14日 04:39