When I added elements to a js array by hand, they appear and can be used normally. If I add them in the Done handler of an ajax request, I can see them in the Chrome debug tools but they are not available for use in code.
I suspect this is related to Cannot access array elements in javascript but cannot figure out how to get access to these items.
function GetUserAllAccessAccountsAsJson() {
var treeData = [];
//these options appear in the jsList tree
treeData.push({ text: "test1", id: "id1", children:true });
treeData.push({ text: "test2", id: "id2", children:true });
treeData.push({ text: "test3", id: "id3", children:true });
var request = GetUserAllAccessAccounts();
request.done(function(dbData, textStatus, jqXHR) {
//I can see these 2 added to the array in Chrome dev tools
//they do not appear in the jsList and Chrome dev tools shows them differently
treeData.push({ text: "testinside4", id: "id4", children:true });
treeData.push({ text: "testinside5", id: "id5", children:true });
});
return treeData;
}
If I console.log the value returned from this function, the Chrome dev tools variable shows only 3 items in the array (the number in the parens at the beginning), but when I expand it shows all 5.
This is the Ajax call which returns a list of about 150 items.
2