2014-04-02 98 views
0

我有一個按鈕,當點擊按鈕時,背景應該變暗並彈出模態。在jQuery中彈出對話框後暗淡的背景

我在C#中非常新,到目前爲止,我已經走到這一步:

<html> 
<head> 
    <title>Create new user/Edit user</title> 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
    <script src="http://code.jquery.com/ui/1.8.24/jquery-ui.min.js" type="text/javascript"></script> 
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/themes/smoothness/jquery-ui.css" type="text/css" media="all" /> 
</head> 
<body> 
    <h4>User Management Module</h4> 
    <button id="opener">New User</button> 
    <div id="wrapper"> 
     <p><asp:Label id="lbl1" runat="server" /></p> 
     <p>Username</p> 
     <form id="Form1" runat="server"> 
      <asp:TextBox runat="server" id="TextBox1"/> 

      <p>Password</p> 
      <asp:TextBox runat="server" id="TextBox2"/> 
      <p>E-mail</p> 
      <asp:TextBox runat="server" id="TextBox3"/> 
     </form> 
    </div> 
    <p></p> 
    <button id="Button.edit">Edit User</button> 
    <div id="Div1"></div> 
    <script type="text/javascript"> 
     $(document).ready(function() { 
      $('#wrapper').dialog({ 
       autoOpen: false, 
       title: 'Create new user' 
      }); 
      $('#opener').click(function() { 
       $('#wrapper').dialog('open'); 
       // $('h4').fadeOut(); 
       // return false; 
      }); 
     }); 
    </script> 
</body> 
</html> 

首先我必須使用:

$('h4').fadeOut(); 

但是,這是一樣的東西有助於消除或隱藏。我沒有實現覆蓋。謝謝。

回答

0

要發出這樣的語法:

modal: true, 

到這裏:

$(document).ready(function() { 

     $('#wrapper').dialog({ 

      modal: true, //blur, darkened 
      autoOpen: false, 
} 
     }); 

將使背景變暗/模糊。這也會阻止內容的操縱。

1

一般來說,我使用Block UI plugin這個。它處理所有混亂的跨瀏覽器CSS的東西,你會跑出來推出你自己的UI組件攔截器,所以你不必!

+0

請問你能證明一下嗎?因爲它不起作用。 – Umitk

+0

你確實需要關注鏈接。該頁面上有許多演示和代碼示例。 – gfish3000