Solved

Refresh ModalDialog window

Posted on 2004-08-12
11
666 Views
Last Modified: 2010-05-18
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?
0
Comment
Question by:Alarming
  • 6
  • 4
11 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11786049
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
0
 
LVL 1

Author Comment

by:Alarming
ID: 11787190
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?
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 100 total points
ID: 11787569
Passing them to popups is actually very easy. Just put the variable in your main window like this:

<script language="javascript">
<!--

var wouldBeQueryString = "fjsoi  some space3189047980#*(@&$#@(*????";

// -->
</script>

Then, in your popup window, you'd get the query string by doing:


opener.wouldBeQueryString;
0
 
LVL 4

Expert Comment

by:reggi635
ID: 11787951
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
0
 
LVL 1

Author Comment

by:Alarming
ID: 11796217
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.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 36

Expert Comment

by:Zyloch
ID: 11850518
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.
0
 
LVL 1

Author Comment

by:Alarming
ID: 11936720
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?
0
 
LVL 1

Author Comment

by:Alarming
ID: 11936739
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").
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11959312
Are you combining vbscript with javascript?
0
 
LVL 1

Author Comment

by:Alarming
ID: 11966878
No, because that would require some pretty extensive passing and such.  I'm sticking with vbscript, which theoretically has a closed flag.
0
 
LVL 1

Author Comment

by:Alarming
ID: 11966960
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.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now