PDA

View Full Version : Layout in a Panel, built by Url Target



jonhartmann
27 Nov 2007, 9:49 AM
I'm working on a small application in which I have displays loading into panels in the center region, using the URL attribute. I'd like to have these panels establish their own layouts... what would the best route be? Can I put the JS needed in the page being loaded, or do I have to build this into the module on the containing page?

Thanks,
Jon

hendricd
27 Nov 2007, 10:05 AM
If you can get to 2.0, this (http://extjs.com/forum/showthread.php?t=18023) or this (http://extjs.com/forum/showthread.php?t=13894) are steps in the right direction.

jonhartmann
27 Nov 2007, 2:00 PM
Unfortunately, I'm limited to 1.1.1 for this project. Is there something I can do along those lines without 2.0?

hendricd
27 Nov 2007, 2:31 PM
Indeed, that's what many do on the 1.1 release. Load the panel from a URL with a script tag in the response, and go nuts.

2.0 is setup to handle this much easier tho.

jonhartmann
27 Nov 2007, 3:03 PM
hendricd,

You're saying that the accepted method for 1.1.1 is to include the code in the response page... I'm trying to do that and it doesn't seem like the JS is doing anything.



<html>
<head>
<title></title>
</head>
<body>
<script>
alert('ding ding');
</script>
hello!
</body>
</html>


As the response loads the hello message, but does not display an alert.

I'm using the following code to load the content:



layout.add('center', new Ext.ContentPanel(thisID, {
title: accountID,
autoCreate: true,
closable: true,
url: 'pages/account.cfm',
params: {
accountID: accountID
},
scripts: true,
loadOnce: true,
fitToFrame: true
}));


Am I doing something wrong when I add the tab?

hendricd
27 Nov 2007, 3:09 PM
Do Not load any entire page into the panel! Send a fragment of static markup(if even necessary) and a script tag.



<script>
alert('ding ding');
</script>

jonhartmann
27 Nov 2007, 3:24 PM
<div>Hi</div>
<script>alert('ding');</script>

Sent through the panel displays "hi", but still no ding. That had been my original test, but I added the <html>... markup to see if that made a difference...

Sorry to turn this into an implementation problem thread vs a concept thread, heh.

hendricd
27 Nov 2007, 3:33 PM
loadScripts:true ?

PS: Never, ever, add an <HTML> tag to a server response that will end up inside one of your DIV's.

jonhartmann
27 Nov 2007, 4:07 PM
Yeah, I know <html> inside stuff is mondo bad, I was just attempting to see if the presence of the tag would cause the script to execute... I fancy myself proficient at JS, but I'm not 100% on quirks of execution and such.

I found the solution finally... you can't pass the loadScripts in to the content panel constructor, as far as I can tell. I had to do this:



layout.beginUpdate();
var panel = layout.add('center', new Ext.ContentPanel(thisID, {
title: accountID,
autoCreate: true,
closable: true,
loadOnce: true,
fitToFrame: true
}));
layout.endUpdate();

panel.getUpdateManager().loadScripts = true;
panel.setUrl('pages/viewAccount.cfm', {
accountID: accountID
});
panel.refresh();


In order to get it to work.

Thank you for the suggestions and help!

hendricd
27 Nov 2007, 4:14 PM
Right on.