PDA

View Full Version : How to replace window.open using "URL content-based" with Ext JS?



michael.leruth
24 Aug 2009, 12:21 AM
I'm new to Ext JS.

I have a javascript method for openning a login popup dialog. This method is based on "window.open()" and uses an URL to load the popup content. The content loaded contains already buttons like "cancel" and "login".

Now, I would like to replace the usage of "window.open()" with Ext JS code.
I provide the code of my "launch" and a "close" popup "Ext JS" functions hereafter.
My problem is that (1) the "closePopupExtJS" funciton doesn't work and (2) I dont' know how to get access to the parent window of my "Ext.Window"...

By the way, I'm not even sure that the usage of Ext.Window is the best approach in order to replace my initial "window.open" javascript method...Please help!



function launchPopupExtJS(popupURL, popupTitle, nWidth, nHeight, viewTools)
{
var win = new Ext.Window(
{
id : popupTitle,
title : popupTitle,
modal : true,
shadow : true,
html: '<iframe src="' + popupURL + '" height="'+nHeight+'" width="'+nWidth+'" frameborder="0" hspace="0" vspace="0" scrolling="no"></iframe>'
}
);

win.show();
}

function closePopupExtJS(id)
{
Ext.WindowMgr.get(id).close();
}

24 Aug 2009, 3:45 AM
We can't help you. "doesn't work" doesn't help us understand what's going on. Where are you calling this method?

24 Aug 2009, 3:45 AM
Think about it. Do you go to your mechanic and say that your car "doesn't work"?

SchattenMann
24 Aug 2009, 3:51 AM
Think about it. Do you go to your mechanic and say that your car "doesn't work"?

maybe...:P

don't work is pretty vague but try using

autoLoad:popupURL instead of html:...

24 Aug 2009, 3:55 AM
autoLoad doesn't work for full pages, which it seems like, he's trying to get working since he's using an iframe :P

SchattenMann
24 Aug 2009, 3:57 AM
indeed...didn't thought on that ;)

michael.leruth
24 Aug 2009, 4:25 AM
Thank you for your reply.

The error message I get is "Ext.WindowMgr.get(id) is undefined" ... while I am sure of the value of the "id" paratemter I use when calling the "closePopupExtJS" method...

It seems that, because I load a new page in the IFRAME ("<html>...</html>"), the code in this new page is "detached" from the opener...

As I said, I am new to Ext JS and may be I'm using a wrong technique to show dialog?

SchattenMann
24 Aug 2009, 5:28 AM
your id window is
id : popupTitle,

i personal don't think that would be the best approach since your title may content spaces, special character whatever...

michael.leruth
24 Aug 2009, 5:32 AM
ok, I will change this but in my tests, this "title" is NOT the problem, since I use a value like "testXYZ" while I'm trying to make this work!!!