2015-10-16 47 views
0

在父頁面上有按鈕點擊打開加載另一個網頁的jQuery UI對話框。在子頁面上有「關閉」按鈕來關閉對話框。我可以在對話框中加載子頁面,但有幾個問題。我搜索了很多網站(嘗試使用銷燬和刪除對話框,或者點擊按鈕)並沒有找到解決方案。希望有人能幫助我解決它。提前致謝。對話框沒有完成關閉,爲什麼不呢?

有我的問題:

  1. 父頁面上的打開按鈕關閉對話框
  2. 點擊對話框中的「關閉」按鈕後消失後,對話框是接近,但股利是即使我改變顯示爲無。

有父:

Parent page

點擊子頁面上的關閉按鈕後。

enter image description here

還有就是我的父頁面代碼:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test.aspx.vb" Inherits="COMM.Test" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title>Test</title> 
    <link rel="stylesheet" href="/include/jquery-ui-themes-1.11.4/themes/smoothness/jquery-ui.css" /> 
    <script language="javascript" src="/include/jquery-2.1.4.min.js" type="text/javascript"></script> 
    <script language="javascript" src="/include/jquery-ui-1.11.4/jquery-ui.js" type="text/javascript"></script> 
    <script language="javascript" src="/include/dailog.js" type="text/javascript"></script> 
<script type="text/javascript" language="javascript"> 
    $(document).ready(function() { 
     $('#btnOpen2').click(function (e) {   
      e.preventDefault(); 
      openDailog(); 
     }); 
    }); 

    </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <div><h1>Test</h1> 
     <div id="somediv" /> 
      <button id="btnOpen2"> Open 2</button> 
    </div> 
    </form> 
    </body> 
</html> 

的子頁面:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestClose.aspx.vb" Inherits="COMM.TestClose" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
<link rel="stylesheet" href="/include/jquery-ui-themes-1.11.4/themes/smoothness/jquery-ui.css" /> 
    <script language="javascript" src="/include/jquery-2.1.4.min.js" type="text/javascript"></script> 
    <script language="javascript" src="/include/jquery-ui-1.11.4/jquery-ui.js" type="text/javascript"></script> 
    <script language="javascript" src="/include/dailog.js" type="text/javascript"></script> 

    <script type="text/javascript" language="javascript"> 
    $(document).ready(function() { 
     $('#btnClose').click(function (e) { 
      e.preventDefault(); 
      closeDailog();  
     }); 

    }); 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <button id="btnClose"> close</button> 
    </div> 
    </form> 
</body> 
</html> 

還有就是我的js代碼:

function openDailog() { 

$("#somediv").load('TestClose.aspx').dialog({ 
    autoOpen: false, 
    modal: true, 
    dialogClass: 'dialog', 
    resizable: false, 
    width: 500, 
    height: 400, 
    title: 'Close diaglog' 
    }); 
    $("#somediv").dialog("open"); 
    return false; 
} 

function closeDailog() { 

$('#somediv').dialog({ 
    autoOpen: false, 
    modal: true, 
    dialogClass: 'dialog', 
    resizable: false, 
    width: 500, 
    height: 400 

}); 

    $("#somediv").dialog("close"); 
    $(".ui-dialog-titlebar").hide(); 
    $("#somediv").css("display", "none"); 


} 

回答

0

既然「 OPE n 2「按鈕在div中,當負載完成時它會被移除。

W3 Schools Load example在刪除加載新內容時div的內容方面的行爲相同。

至於第二點,加載子頁面並沒有改變,所以爲什麼它會被刪除?


您可能使孩子頁面重載父雖然你可能使用localStorage的項目在HTML5沿着標誌傳遞到觸發父裝載的挑戰。我懷疑你可以清空其HTML的「somediv」div來作爲清除頁面的一種方式。

+0

我想要子頁面(對話框完全消失)和父頁面重新加載。 – user819774

+0

如果只關閉對話框,我將顯示器更改爲div上沒有顯示,但它沒有正確執行。 – user819774