PDA

View Full Version : [SOLVED] ContentPanel loadOnce is ignored



watrboy00
26 Sep 2007, 5:55 PM
I have a BorderLayout with north, center, and south regions. The center region is tabbed and by default is loaded with 3 ContentPanels with urls specified on creation. My problem is every time the 'home' is clicked it reloads the panel even though loadOnce is set to true on that ContentPanel. Any ideas why it does this?



var Layout = function() {
var layout;

var north;

var center_issues;
var center_home;
var center_my_home;

var south;

return {
init: function( options ) {
/*
*
* LAYOUT OPTIONS
*
*/

this.options = options;

/*
*
* MAIN LAYOUT & REGION DEF
*
*/

layout = new Ext.BorderLayout(document.body, {
north: {
split: false,
titlebar: false
},
center: {
titlebar: false,
autoScroll: true,
closeOnTab: true,
tabPosition: "top",
alwaysShowTabs: true
},
south: {
split: false,
initialSize: 20,
minSize: 20,
maxSize: 20,
titlebar: false,
collapsible: true,
animate: false
}
});

/*
*
* START LAYOUT DEF
*
*/

layout.beginUpdate();

/*
*
* NORTH REGION
*
*/

north = new Ext.ContentPanel('header', {
title: 'Tool Bar',
closeable: true
});

layout.add( 'north' , north );

/*
*
* CENTER REGION : ISSUES, HOME, MY HOME PANEL
*
*/

center_issues = new Ext.ContentPanel('issues', {
title: 'Known Issues',
closable: false,
url: "issues.asp",
loadOnce: true,
background: true
});

layout.add( 'center' , center_issues );

center_home = new Ext.ContentPanel('home', {
title: 'Home',
closable: false,
url: "home.asp",
loadOnce: true,
background: true
});

layout.add( 'center' , center_home );

center_my_home = new Ext.ContentPanel('my_home', {
title: 'My Home',
closable: false,
url: "my_home.asp",
loadOnce: true,
background: true
});

layout.add( 'center' , center_my_home );

/*
*
* SOUTH REGION
*
*/

south = new Ext.ContentPanel('footer', {
title: 'Status Bar',
closable: true
});

layout.add( 'south' , south );

/*
*
* END LAYOUT DEF
*
*/

layout.endUpdate();

/*
*
* SHOW DEFAULT PANEL
*
*/

layout.showPanel( this.options.panel );
}
};
}();

Ext.EventManager.onDocumentReady( Layout.init.createDelegate( Layout , [{panel: 'home'}] ) , Layout , true );

watrboy00
29 Sep 2007, 8:18 PM
Do you think that the cache settings in the browser/script would cause it to reload?

Animal
29 Sep 2007, 10:47 PM
No. If this is happening, then it's a bug. But I suspect user error. You actually see the request being sent using Firebug do you?

watrboy00
30 Sep 2007, 8:57 PM
Did a little more debugging on this. I have a menu that when an item is clicked it changes the "center_home" center panels url using the setUrl function. However, my code was the following:


layout.findPanel('center_home').setUrl( "home.aspx");

And if I would have read the docs correctly I would have known that the loadOnce option had to be passed in each time you use the .setUrl funciton


setUrl

public function setUrl( String/Function url, [String/Object params], [Boolean loadOnce] ) Set a URL to be used to load the content for this panel. When this panel is activated, the content will be loaded from that URL. Parameters:
url : String/FunctionThe URL to load the content from or a function to call to get the URL
params : String/Object(optional) The string params for the update call or an object of the params. See Ext.UpdateManager.update (http://extjs.com/forum/../deploy/ext/docs/output/Ext.UpdateManager.html#update) for more details. (Defaults to null)
loadOnce : Boolean(optional) Whether to only load the content once. If this is false it makes the Ajax call every time this panel is activated. (Defaults to false)
Returns:
Ext.UpdateManagerThe UpdateManager


This method is defined by ContentPanel.



Thanks Animal for looking at this though.