PDA

View Full Version : Ext.onReady on popup window?



dolittle
6 Sep 2007, 8:23 AM
Hi

How can I check from the opener window that a popup window is ready?
Can I use something like Ext.onReady?

Thanks

Animal
6 Sep 2007, 10:04 AM
Ah, you mean window.open(), not a BasicDialog.

You'd use Ext.onReady in the page that you load there.

It's a seperate window, with a seperate document.

If you want stuff to happen in the opener, you'll have to use window.opener in the popped up document.

But why are you opening browser windows.

I took the decision never to do this. We use BasicDialogs (and will use Ext Windows in Ext 2.0)

dolittle
6 Sep 2007, 11:37 AM
I agree with you. I hate popups but we decided to have them as the first step of the project and then move to BasicDialogs.

I want to have logic only on the opener window and not on the child windows.
For this purpose I have to know when the child window`s DOM is ready.

newWin = window.open('newWin.html', 'newWin, 'status=no, resizable=yes, height=380, width=400');
Ext.EventManager.on(newWin, 'load', function() {
//do something with the DOM
});

This works on FF but not on IE but I guess it`s wrong in any case.
I`m looking for something like onReady but maybe simpler because I have only DOM and CSS wtih no javascript on the child window.
I thought of putting a script on the end of the child window but I want to avoid it:

<script type="text/javascript">opener.somefunction();</script>

Thanks

Animal
6 Sep 2007, 11:46 AM
It's very non-standard, so not surprising that that won't work.

I thiink you;ll have to do what I suggest and have the Ext.onReady script fire in the newly opened window, and reach back into opener to trigger something.

Maybe the url can include an onready=ccxxxx parameter where cbxxx is a generated function name.



var cbName = "cb" + ext.id();
window[cbName] = function() {
// handle popup's startup stuff
};
window.open(url + "&onready=" + cbName);


And the server resource could generate an onReady script which could call that callback in window.opener.document.

I think you;re going down a path that you won't be able to get out of though.

The issues you will code round when using window popups are so different to those when using Ext.BasicDialogs that you will never be able to just switch over.

It's a real challenge using BasicDialogs for popping up arbitrary pages.

You have to remember that they are all in one document, and element ids must be unique, so any page or page fragment authors may NOT specify element ids. These must all be generated.

dolittle
6 Sep 2007, 11:51 AM
I`ll try that.

And keeping in mind the unique id thing is important.

Thanks