Kann nicht jQuery-plugin jsTree zunächst wählen Sie einen Knoten

Habe ich jsTree laden von Daten aus einer JSON-Seite und zeigt es korrekt an. Ich bin versucht, wählen Sie den root-Knoten standardmäßig, aber ich kann nicht ankommen es zu wirken.

Hier mein jQuery:

$(function () {
    $("#demo1").jstree({ 
        "plugins" : [ "themes","json_data","ui" ],
        "json_data" : {
            "ajax" : {
                "url" : "categorytreejson.asp"
            },
            "ui" : {
                "initially_select" : [ "root" ]
            },
        }
    });
});

Hier mein JSON von categorytreejson.asp, die überprüft, mit JSONLint:

{
  "data": "root",
  "attr": {
    "id": "root"
  },
  "children": [
    {
      "data": "Photography",
      "attr": {
        "id": "Photography"
      },
      "children": [
        {
          "data": "Lenses",
          "attr": {
            "id": "Lenses"
          },
          "children": [
            {
              "data": "Telephoto",
              "attr": {
                "id": "Telephoto"
              }
            },
            {
              "data": "Macro",
              "attr": {
                "id": "Macro"
              }
            },
            {
              "data": "Other",
              "attr": {
                "id": "Other"
              }
            }
          ]
        }
      ]
    }
  ]
}

Hier ist die resultierende HTML:

<li class="jstree-last jstree-open" id="root"><ins class="jstree-icon">&nbsp;</ins><a class="" href="#"><ins class="jstree-icon">&nbsp;</ins>root</a>
    <ul style="">
        <li class="jstree-closed" id="Photography"><ins class="jstree-icon">&nbsp;</ins><a class="" href="#"><ins class="jstree-icon">&nbsp;</ins>Photography</a>
            <ul>
                <li class="jstree-last jstree-closed" id="Lenses"><ins class="jstree-icon">&nbsp;</ins><a href="#"><ins class="jstree-icon">&nbsp;</ins>Lenses</a>
                    <ul>
                        <li class="jstree-leaf" id="Telephoto"><ins class="jstree-icon">&nbsp;</ins><a href="#"><ins class="jstree-icon">&nbsp;</ins>Telephoto</a>
                        </li>
                        <li class="jstree-leaf" id="Macro"><ins class="jstree-icon">&nbsp;</ins><a href="#"><ins class="jstree-icon">&nbsp;</ins>Macro</a>
                        </li>
                        <li class="jstree-last jstree-leaf" id="Other"><ins class="jstree-icon">&nbsp;</ins><a href="#"><ins class="jstree-icon">&nbsp;</ins>Other</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </li>
</li>
</ul>
</li>
</ul>
</li>

Und die daraus resultierenden Daten-Objekt angezeigt firebug:

args: []
inst: Object { data={...}, get_settings=function(), _get_settings=function(), more...}
rlbk: false
rslt: undefined

Ich gehe davon aus, dass die meisten das problem, weil die Folge leer ist, aber ich bin mir nicht sicher, warum?

InformationsquelleAutor Chris | 2012-03-12
Schreibe einen Kommentar