2014-01-30 41 views
0

我有一個模式對話框,用戶可以在其中登錄的窗體打開。如果用戶尚未註冊,則會出現鏈接在那個模式對話框裏面打開另一個帶有註冊表單的模態對話框。問題在於造成衝突,看起來很奇怪。我想我需要關閉登錄表單模式對話框,然後打開註冊模式對話框。Jquery Bootstrap Modal ...如何從另一個模態對話框中打開不同的模式對話框

// the button to open the login modal dialog 
<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#login-dialog"> 
     Login 
     </button> 

//this button is inside the login modal dialog, a will open the registration modal dialog 
'<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#registration-dialog"> 
     Register 
     </button> 

回答

2

即使在另一個對話框中也可以根據需要打開/關閉對話框。使用這種風格:

div.modal { 
    display:none; 
} 

有了這個網站:

<button id="login">Login</button> 
<div id="login_modal" class="modal">this is your login modal. 
    <br/> 
    <br/> 
    <button id="register">Register</button> 
</div> 
<div id="register_modal" class="modal">this is your register modal.</div> 

你可以做到這一點在JavaScript:

$("#login").click(function() { 
    $("#login_modal").dialog({ 
     modal: true 
    }); 
}); 

$("#register").click(function() { 
    $("#register_modal").dialog({ 
     modal: true 
    }); 
    $("#login_modal").dialog("close"); 
}); 

這裏有一個fiddle