mbraak / jqTree

Tree widget for jQuery
https://mbraak.github.io/jqTree/
Apache License 2.0
1.02k stars 177 forks source link

documentation problem Example 5 #245

Closed aichingm closed 10 years ago

aichingm commented 10 years ago

On http://mbraak.github.io/jqTree/examples/load_on_demand.html the example says the "first level of data" should look like

[
  {
    label: 'Saurischia',
    id: 1,
    load_on_demand: true
  },
  {
    label: 'Ornithischians',
    id: 23,
    load_on_demand: true
  }
]

Returning this from the server will fail. Jquery tries to parse the json and will call the "error" function in $.ajax() because the response is not a valid json file

please replace the example with

[
    {
        "label": "node1",
        "children": [
            {
                "label": "child1"
            },
            {
                "label": "child2"
            }
        ]
    },
    {
        "label": "node2",
        "children": [
            {
                "label": "child3"
            }
        ]
    }
]

or add something like this to the error function:

if(console){
   console.log("loading data from remote failed! is your json valid?");
}

thanks, Mario

mbraak commented 10 years ago

Thanks a lot! I fixed the example in the dev branch.

aichingm commented 10 years ago

Thank you!