Solved

Refresh ModalDialog window

Posted on 2004-08-12
11
672 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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
 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

770 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