Here Iam creating two dialog boxes on the click on links.When Dialog box no. 1 is open and I press escape key then it gets closed but this is not the case with dialog box no. 2.Why so?

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<a href="#" id="PopUpLink">Open Popup</a>
<br><br><br>
<input type="button" value="Click me" id="Click_me">
<div name="Pop" title="Popup" id="Popup1"><a href="#" id="PopUpLink2">Hello,This is my first dialog box</a></div>

<div name="Pop" title="Popup" id="Popup2"><a href="#" id="PopUpLink3">Hello,This is my second dialog box</a></div>



$(function() {


      $("#Popup1").dialog({
          autoOpen:false,
          modal:true,
          title:"Pop Up 1",
          show:"drop"

      });

          $("#Popup2").dialog({
          autoOpen:false,
          modal:false,
          hide:"explode",
          title:"Pop Up 2",
          open:function(){
          $("#Popup1").dialog("close")}

      });


      $("#PopUpLink").click(function(){
        $("#Popup1").dialog("open")          
      });

    $("#PopUpLink2").click(function(){
        $("#Popup2").dialog("open")          
      });

      $("#PopUpLink3").click(function(){
        $("#Popup1").dialog("open") 
        $("#Popup2").dialog("close") 
      });

  });
Member Avatar for stbuchok

I believe this is because the dialog doesn't have focus. You will need to find a way to give the dialog focus.

Change the autoOpen for box 2. IT MIGHT WORK... I haven't tried it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.