Hi Ricky,
code running in the iframe (custom dialog content) can close the dialog in the following
way:
1, send message to your plugin to indicate the dialog needs to be closed:
parent.postMessage('CloseMyDialog', '*');
2, your plugin intercepts the message via MessageReceived function and closes the dialog:
MessageReceived: function(data, sourceWindow) {
switch (data) {
case 'CloseMyDialog':
window.alert('About to close dialog');
api.closeDialog('my-dialog');
break;
}
}
If the above doesn't work for you, it could mean that:
- MessageReceived function isn't invoked - make sure to have [*] before api.register()
call
- api.closeDialog() function isn't working - in this case I need to fix it for IE9
[*] accept message events from iframe (custom dialog content) origin
api.options({
allowedMessageOrigins: 'http://nicedomain:8080'
/* OR */
allowedMessageOrigins: ['http://nicedomain1:123',
'https://nicedomain2:345']
});
I'm going to investigate this issue on IE9 myself to see if the above code is really
working there.
Vojtech
----- Original Message -----
From: "Richard Hopper" <Richard.Hopper(a)netapp.com>
To: "Vojtech Szocs" <vszocs(a)redhat.com>
Cc: engine-devel(a)ovirt.org, "Christopher Morrissey"
<Christopher.Morrissey(a)netapp.com>
Sent: Monday, June 17, 2013 8:16:03 PM
Subject: IE9 Issue with UI Plugin
Hi Vojtech,
I had previously sent you an email about IE9 compatibility where the problem
we were having was solved by omitting console logging when a console was
unavailable (i.e. IE). However, it is looking like IE9 may have a bigger
issue with regards to the plugin framework.
Now that we have gotten dialogs to open via dynamically inserted buttons
within RHEV tabs (for example, a NetApp button in the Storage tab), we can
go through our whole process with the exception of closing the window. In
all other browsers, our dialog will close as expected, but in IE the window
remains open. It can be closed by hitting the red "x" in the corner, but it
appears the code in the frame itself cannot close the window, with a console
message in the dev tools of IE9 showing an error of "'Math' is
undefined".
I've read up on this, and it seems like this is a very widespread error in
Internet Explorer concerning the manner/order in which iframes are
dynamically inserted.
I've copied engine-devel in case anyone has similar issues/solutions, but it
seems as though we need some sort of clause in the plugin framework for IE
when it comes to dynamic insertion of new windows.
- Ricky Hopper