?
Solved

Refresh ModalDialog window

Posted on 2004-08-12
11
Medium Priority
?
686 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

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