PDA

View Full Version : Expand path in tree, callback



frankbolviken
27 Sep 2011, 12:02 AM
Hi,

We have a method like the following:

expandPath: function(path, firstload, site) {
var controller = this;
callback = function(bSuccess, oLastNode) {
if(oLastNode !== null) {
oLastNode.expand();
if(firstload !== undefined && firstload == true) {
controller.initNavigationGrid(site, path == "/null" ? "" : path);
}
}
};
this.getNavigationPanel().selectPath(path, 'name', '/', callback);
},
The problem we are facing is that the callback function is executed twice(the expandPath function is only executed once).
If we change the "this.getNavigationPanel().selectPath(path, 'name', '/', callback);" with this.getNavigationPanel().expandPath(path, 'name', '/', callback); the callback is only run once, but the last node is not selected, which is a functionality we need. Is there any way of inside the callback manualle selecting the last node, or how can we avoid the callback beeing executed twice when using selectPath instead of expandPath?

Any help would be greatly appreciated.

Frank

skirtle
27 Sep 2011, 12:32 AM
Put in a breakpoint, why is it being called twice?

frankbolviken
27 Sep 2011, 12:33 AM
I can't put in breakpoints because it's on pagerefresh, and the breakpoints go away.
but i've put "alerts" in the method, and the method is only called once, but the callback is executed twice.

skirtle
27 Sep 2011, 12:40 AM
I can't put in breakpoints because it's on pagerefresh, and the breakpoints go away.

What are you using to put in breakpoints? Both Firebug and the Chrome Developer Tools will keep breakpoints across page refreshes.

If you really can't keep breakpoints across a page refresh then just don't run the code on page refresh: add in a button that run it on click.

frankbolviken
27 Sep 2011, 12:42 AM
We also run the code when we navigate the application, and it works fine then it seems.
We use Chrome, and on pagerefresh, the js code is reloaded, and the debug points are removed. I guess it's something with the new fancy dynamic loading of scripts?

skirtle
27 Sep 2011, 2:08 AM
I guess it's something with the new fancy dynamic loading of scripts?

Possibly. Should be trivial to test. Just add the files you want to put breakpoints in using a normal script tag instead. You probably only need one file.