Login Register

Populating a tree with a server call works fine only the first time on IE

I use thid code on my jsp page.

div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore" url="/action.do?....
div dojoType="dijit.Tree" id="tree" store="continentStore"

On IE it works fine only the first time.
When I reload the page to load new data from server, the tree doesn't loads properly, and tree seems to load the same data stored on first time.

On Firefox I don't have any problem and tree works fine every time.

Is there a way to solve my problem?

Requery on IE

Did you receive an error message thrown by your ItemFilereadStore?
I had the same problem (ONLY with IE 6 & 7). My workaround was to get all the data loading in a dojo.addOnLoad() function. So data ist loaded after the page is generated.
Seems that IE does it (again) in his own way.
This code works in other browsers even without waiting with data-loading. To have total confusion: Not all IE 6 or 7 shows the same behavior!

My suggestion would be something like this:

myStore = dojo.data.itemFileReadStore({url: "somephp"});

var gotError = function(error, request) {
alert(error);
}

var done = function(items, request) {
// done something with my data AND
// sent it to a DOM id.
dojo.byID('myNodeID').innerHTML = data;
}

function loadData() {
myStore.fetch({
onError: gotError,
onComplete: done;
)};
}

dojo.addOnLoad(
loadData();
)

I got errors in IE, if I loaded the data directly (myStore.fetch), not placed in a addOnLoad.
Hope, that helps.

Michael