3

これは、これに対処するための最後の手段です。

問題は、以下のサンプル データから特定の値を取得できないことです。

急いでいるので、この問題について何か答えていただければ幸いです。

これは私が持っているコードです。

  $("#organize").jstree(
  {
      "core": {'animation': 100},
      "json_data": {
          "data": [
          {
              "data": "J",
              "id": "10600_10600",
              "metadata": {
                  "id": "10600_10600",
                  "name": "10600_10600"
              }
          }]
      },
      "themes": {
          "theme": "classic",
          "url": "<%=request.getContextPath()%>/approval/css/jstree.css"
      },
      "plugins": ["themes", "json_data", "ui"]

  }).bind("dblclick.jstree", function (e)
  {
      alert($('#organize').jstree('get_selected').attr('id'));
      ////////////TODO: Can not get ID here/////////////////
  });


  $('#add').click(function ()
  {

      //HERE I can get 'name' of the selected node but 'id' is undefined.
      var name = $("#organize").jstree('get_selected').text();
      var id = $("#organize").jstree('get_selected').attr('data');

  });
4

1 に答える 1

4

JS ツリーは、"attr" JSON プロパティを使用して、属性と値をノードに追加します。データセクションを次のように変更します。

$("#organize").jstree(
  {
      "core": {'animation': 100},
      "json_data": {
          "data": [
          {
              "data": "J",
              "attr": {
                  "id": "10600_10600",
                  "name": "10600_10600"
              }
          }]
      },
      .....
于 2013-03-14T05:03:55.020 に答える