PDA

View Full Version : loading tab panel content



orla
21 Sep 2006, 11:05 AM
Hi there

I've got a tab panel with a couple of tabs each of which have their content loaded using setUrl. The page that the url points to contains a grid and I'm calling grid initialisation function from the onUpdate method of the tabs UpdateManager.

The first time the page loads, the call to initialise the grid fails on grid.render() however subsequent tabbing works correctly and the grid successfully loads.

If I put in some kind of a delay before the grid.render (say an alert() call) the grid loads without problem, so I'm wondering if I'm using the wrong event to trigger the grid initialisation - is there another event that is fired after the url pointed to by the tab has been loaded?


The page with the TabPanel has the follwoing



var tabPanel = new YAHOO.ext.TabPanel('tabPanel');
var load_grid = function(type) {
Grid.init('grid-div', datamodel-target);
};

var tab = tabPanel.addTab('my_tab', 'my_tab');
tab.setUrl(tab-url, null, false);
var mgr = tab.getUpdateManager();
mgr.onUpdate.subscribe(load_grid);


And the page pointed to by the url has the grid div tag <div></div>

Any help would be appreciated
Thanks
O.

jack.slocum
21 Sep 2006, 11:55 AM
Your code looks fine. It could be the browser is failing behind. In the grid itself I have this problem sometimes and the only fix is setTimeout.



var load_grid = function(type, delayed) {
if(delayed !== true){
setTimeout(load_grid.createDelegate(null, [type, true]), 1);
return;
}
Grid.init('grid-div', datamodel-target);
};


Let me know if that fixes it. If it does, I can add the logic built in to update manager so you don't have to do it manually.

Jack

orla
21 Sep 2006, 11:12 PM
Hi Jack,

That worked a treat.

Thanks for your help.
Orla

techno_adi
4 Oct 2006, 1:57 AM
Hi orla,

Can i have the source code. Even i am trying to do the same and facing some problems?

Thanks a lot

techno_adi
4 Oct 2006, 4:37 AM
Hi Jack,
I have mailed you the files in [email protected]
Please have a look at it, it gives me "invalid argument" error.
Thanks a lot

techno_adi
4 Oct 2006, 6:37 AM
Hi Jack,
I have mailed you the files in [email protected]
Please have a look at it, it gives me "invalid argument" error.
Thanks a lot

Thanks a lot. It fixes for me too.(i mean on my main web-page) :)

jack.slocum
4 Oct 2006, 7:24 AM
Great, glad it fixed it for you. The need for a setTimeout when switching from display:none to display:block is irritating, but at at least FF and IE are both consistent about it.