PDA

View Full Version : Loading a ContentPanel (or TabPanel)



jamaljohnson
15 Nov 2006, 7:39 AM
It's probably hidden in plain sight and I'm just not seeing it, but i'm trying to re-use a tab / content panel with a _different_ url in certain instances.
Here is what i have setup basically:



//this = Example object
this.layout.add('center', new YAHOO.ext.ContentPanel('content',{title: 'Home', closable: false}));

var centerLayoutReg = this.layout.getRegion('center');
if( centerLayoutReg.hasPanel(id) ){
// panel / tab exists, show it
centerLayoutReg.showPanel(id);
// TODO: now i want to reload with a diff url... How do i do this???
}else{
this.layout.add( 'center',
new YAHOO.ext.ContentPanel('feeds', {
title: title,
fitToFrame:true,
closable: true,
autoCreate: {tag: 'iframe', src: content, frameBorder: 0, id: id}
})
);
}


so after:
centerLayoutReg.showPanel(id);how do i set the url of this panel to be somePage.html?

Thanx in advance....

jack.slocum
15 Nov 2006, 8:26 AM
There are a few way to do it, the easiest is:

centerLayoutReg.getPanel(id).getUpdateManager().update('foo.php');

Here's shorter but less flexible:

getEl(id).load('foo.php');

and if you call it before the panel is "activated":

centerLayoutReg.getPanel(id).setUrl('foo.php');

All of these methods take additional parameters as well.

jamaljohnson
15 Nov 2006, 1:07 PM
i've tried a bunch of ways but i always get this error, which is weird because the tab is already loaded, i'm just trying to load it again with a new url:

YAHOO.util.Connect has no properties:
216this.transaction=YAHOO.util.Connect.asyncRequest(method,url,callback,params);}},formUpdate:function(form,url,reset,callback){if(this.beforeUpdate.fireDirect(this.el,form,url)!==false){this.showLoading();formEl=YAHOO.util.Dom.get(form);if(typeof url=='function'){url=url();}

any ideas?

jbowman
15 Nov 2006, 2:37 PM
looks like you don't have the yui connection library loaded.

jamaljohnson
16 Nov 2006, 11:39 AM
still cannot get this working. here's what i have now:


var centerLayoutReg = this.layout.getRegion('center');
if( centerLayoutReg.hasPanel(id) ){
if( reloadable ){
centerLayoutReg.getPanel(id).setUrl("myPage.html");
//centerLayoutReg.getPanel(id).setUrl( content, null, false );
//centerLayoutReg.getPanel(id).refresh();
//centerLayoutReg.getPanel(id).el.getUpdateManager().update( content );

centerLayoutReg.getPanel(id).getUpdateManager().update( "myPage.html" );
}
centerLayoutReg.showPanel(id);


i've also tried doint just the update() call and no setUrl call (but calling showPanel() first in that case). i don't get the connection error (i included the connection library now. it must not use Connection the first time? only on a 'reload'?), but the page does not change. all it does is activate the tab... any thoughts?

Thanx again...

jamaljohnson
16 Nov 2006, 11:46 AM
a little more inspection using the firefox Live HTTP Headers plugin, the server GET is actually being executed, but it just looks like the contents of the ContentPanel / TabPanel / IFrame is not being updated onResponse.... is there any method i need to call to refresh that content?

tryanDLS
16 Nov 2006, 3:21 PM
Can you set a BP in UpdateManager's processSuccess/processFailure methods and see what's happening?

jamaljohnson
16 Nov 2006, 4:05 PM
yeah, i'll check that out...

jamaljohnson
16 Nov 2006, 4:43 PM
so its actually 'working' in a live environment, meaning i put a break point in processSuccess and it stops there. however, the response.responseText = "4877 characters" which is actually how many characters are in the file i'm trying to load. which is weird 'cause shouldn't responseText be the contents of the actual html file?

also, it doesn't use the UpdateManager the first time? meaning when i first create the tab / contentpanel?

jamaljohnson
16 Nov 2006, 5:03 PM
still can't figure out the deal, but i found a work around:


document.getElementById(id).src = content;

that gets the iframe and sets it new location.

if anyone still has any ideas as to why it's not working otherwise, please lemmeno.
thanx again!

jack.slocum
16 Nov 2006, 8:58 PM
ohhhh you are using an iframe.

You dont want to use update manager then, just set the src (as you are doing thru the getElementById).

centerLayoutReg.getPanel(id).getEl().dom.src = ..;

Or you can update it directly as you are doing.

jamaljohnson
17 Nov 2006, 8:49 AM
yup ;)

new YAHOO.ext.ContentPanel('feeds', {
title: title,
fitToFrame:true,
closable: true,
autoCreate: {tag: 'iframe', src: content, frameBorder: 0, id: id}
})

cool, good to know of the yahoo.ext method. the more i learn about this lib, the more i like.
"good form jack"

thanx!