I am looking for the most direct way to retrieve values that have been
entered by the user into a modal dialog box. I realize that I can just
write the values to a global object or variables in the onAccept()
method, but isn't there a way to get the values directly from the
dialog box. I thought I could do something like this:
<dialog id="mydialog"
...
>
<property id="myproperty">
...
</dialog>
Then in the dialog:
function onAccept()
{
window.myproperty = "foo";
}
and in the main function:
var dlg = window.openDialog(..., "modal");
var result = dlg.myproperty;
Unfortunately, I can't find any examples of this and I haven't managed
to find the right approach by trial and error.
>var dlg = window.openDialog(..., "modal");
>var result = dlg.myproperty;
>
>
I have this nasty suspicion that the window.close of the dialog destroys
all of the global variables making it impossible to return a property.
Generally the most convenient way is to pass input and output parameters
in a JavaScript object e.g.
function showDialog(aIn) {
var params = { in: aIn, out: null };
window.openDialog(..., "modal", params);
return params.out;
}
then the dialog's script would have
var params = window.arguments[0];
var in = params.in;
etc.
--
Warning: May contain traces of nuts.