DMXzone Lightbox Support Product Page

Answered

Popup forms with Dreamweaver

Asked 01 Aug 2011 13:04:12
1
has this question
01 Aug 2011 13:04:12 Jim Elliott posted:
If like me you are a bit lazy and use Dreamweaver's insert and update using a lightbox web page is a great idea. However the dreamweaver wizard will load whatever you decide to be the next page within the lightbox.

So you want to close the lightbox automatically and refresh the underlying page. This is not as difficult as it seems and thanks to DMX zone tech staff for pointing me in the right direction.

Firstly on the calling page you need to put a listener that will refresh itself if a box is closed (don't worry it will not do is if cancel is chosen).

Just add this two javascript functions to the page in the <head> area (remember to place them in script tags):

$(function() {  
 // wait for lightbox instance  
  (function() {  
   if (!DMX.Lightbox.instance) {  
    window.setTimeout(arguments.callee, 800);  
    return;  
  }  
    
DMX.Lightbox.instance.addEventListener('contentLoaded.redirector', function(){
    //when lightbox is closed
    this.addEventListener('afterClose', function() {
    //refresh the parent
    window.location = window.location;
      });  
   });  
  })();  
 });



Now to the dreamweaver bit in the form. If you use the wizards or just use the insert or update on your own forms then Dreamweaver will lay down the following code just after the insert or amend:

  $insertGoTo = "gosomewhere.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}


This example is from an insert. If you were updating the variable would change to $updateGoTo.

just replace the line

header(sprintf("Location: %s", $insertGoTo));



with the following three lines


echo("<script language=\"javascript\">");
echo("top.location.href = \" ").$insertGoTo.("\";");
echo("</script>"); 


and that's it. Your form will do the desired action, the window will close and the underlying page will be refreshed.

Edited by - Jim Elliott on 01 Sep 2011  10:41:10

Edited by - Jim Elliott on 01 Sep 2011  10:41:39

Replies

Replied 15 Sep 2011 08:37:58
15 Sep 2011 08:37:58 Lisa Baker replied:
I got it to work. []

Per another post I read to get the popup to close, I selected the
form and in the Tag Inspector Behaviors palette I added:
DMXzone > DMXzone Lightbox > Control DMXzone Lightbox
I used the options:
Act In: Current Window and Action: Close
This took care of the closing the popup.

To get the original page to reload I just added this to the body tag in the popup
onunload="parent.parent.top.document.location.reload();">


Edited by - Lisa Baker on 15 Sep 2011  08:39:13
Replied 21 Sep 2011 11:50:14
21 Sep 2011 11:50:14 Miroslav Zografski replied:
Hello Jim,

thanks for your contribution.

Reply to this topic