Link to home
Start Free TrialLog in
Avatar of Alarming
Alarming

asked on

Refresh ModalDialog window

Hello, I am using a ShowModalDialog command to open a popup window.  This window is populated with data from a table, using SQL queries.  However, recently I have decided to add buttons which can add or delete records shown in the window from the database.

While I can add or delete said records, I run into a problem: Changes made to the underlying table are not reflected in the window.  To solve this, the simplest solution is to just reload the window (as if it were just opened again, as there are no other possible changes to enact except for those to the underlying table).  However, a window.location.reload statement does not seem to work.

How does one reload or refresh a Modal Dialog box?
Avatar of Zyloch
Zyloch
Flag of United States of America image

Hi

Unfortunately, modal dialogs were made for display-only. The only way is to load your contents in a hidden iframe and then replace the contents in the modal dialog box with the new contents.

Regards,
Zyloch
Avatar of Alarming
Alarming

ASKER

How difficult exactly would that be to do in general?  I'm not particularly keen on using an iFrame setup, and moreover the window could require a number of dynamic changes.  (Basically adding, editing, and deleting files via other modal popups from the page).

I suppose that means it might be necessary to make the page just a standard popup, but that creates an issue.  Currently the reason for the modal popup is so that a parameter can be passed denoting a given project (whose subrecords are then displayed).  These project names have a pretty loose format (commas, spaces, and other special characters are allowed) so they're not very easy to put in as query strings- and right now the setup is on a network share and not a server, so server side variables are out.

So then, I suppose follow up things: How flexible is the iFrame setup?   And is there a way to pass parameters efficiently to some standard popup window in a similar way as one can to a Modal Dialog box?
ASKER CERTIFIED SOLUTION
Avatar of Zyloch
Zyloch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
window.location.reload defnitely won't work.

Try using

window.location.href = 'sameTemplatename followed with required parameters as URL string'

Its basically calling the same template with a redirect. Looks like a reload.

Hopefully this may help u

REGGI
Well, the href and open commands don't work either, I probably should have mentioned that Reggi.

Basically I'm switching over to a standard popup that will sort of emulate the format of the modal dialog.  However, Zylock, for some reason the opener command doesn't want to work.

Right now I'm trying to make the statements as "window.opener.pass_recordname" (where recordname is set in the parent window function that makes the popup.

However, it gives me an error "object doesn't support" etc etc.  From looking at the opener documentation, it seems to state it's only supposed to be used for an iframe or a frame.  I'd prefer to leave the function a bit loose to just go to the parent, but if I need to I suppose some method of just naming and referrencing the window by hard code might be effective too.
Actually, opener is more often used for parent child window relationships. You could being conservative for a test and make the pass_recordname variable not have a "_" in it. Also, make sure that in the main window, the stuff inside pass_recordname doesn't have doubled up quotes, like var s = 'what's up' that should be var s = 'what\'s up'

You can also try putting the alert(window.opener.pass_recordname) and see what happens.
I think I've got the passing right (needed to make sure the opener variable was global), but another issue remains.  Basically I can get the stuff passed, but since the new window refreshes itself (which was its original advantage over the showmodal), I need some way to disable the parent window's ability to create more of those new windows while one is in use.

Basically, right now an issue occurs in that more than one project can be opened in a new window but they are both running off the same variable information.

So window A opens and sets the global variable Project to "A".  Then window B is opened, and sets Project = "B".  Now, when A tries to refresh and checks what Project equals, it displays the same information as Window B.  So then, I have to stop a second new window from being opened until the first is closed (which had previously not been a problem with the modal one, by definition).

Any advise?
Right now what I'm trying is something which goes like:

dim fullview

If(IsNull(fullview) OR fullview.closed) THEN
   <don't let another window open>
ELSE
   fullview = window.open(<stuff>)
END IF

Unfortunately, fullview.closed always gives an error as it states that the object is not correct in some way ("object required").
Are you combining vbscript with javascript?
No, because that would require some pretty extensive passing and such.  I'm sticking with vbscript, which theoretically has a closed flag.
I solved the issue of having to worry about it being open or not by just not opening the new window as a "_blank" and instead just making sure it was always going to one of the same name.  By that merit, it would always be replacing the original if a new one was opened, preventing conflicts and confusion.