Static & Async mixing JSON demo

This is a simple example - you could enhance it not to pollute the global namespace.

01.var stat =  [
02.    { attributes : { "id" : "node_1" }, data : "Node 1" },
03.    { attributes : { "id" : "node_2" }, data : "Node 2", state : "closed"},
04.    { attributes : { "id" : "node_3" }, data : "Node 3" }
05.];
06.$(function () {
07.    $("#sa_json_1").tree({
08.        data : {
09.            type : "json",
10.            async : true,
11.            opts : {
12.                async : true,
13.                method : "POST",
14.                url : "async_json_data.json"
15.            }
16.        },
17.        callback : {
18.            // Make sure static is not used once the tree has loaded for the first time
19.            onload : function (t) {
20.                t.settings.data.opts.static = false;
21.            },
22.            // Take care of refresh calls - n will be false only when the whole tree is refreshed or loaded of the first time
23.            beforedata : function (n, t) {
24.                if(n == false) t.settings.data.opts.static = stat;
25.            }
26.        }
27.    });
28.});