简体   繁体   English

Jquery Bootstrap Modal ...如何从另一个模态对话框中打开另一个模态对话框

[英]Jquery Bootstrap Modal… How to open a different modal dialog from inside another modal dialog

I have a modal dialog that opens with a form inside for users to sign in. If the user has not registered yet, there is a link in that modal dialog to open up another modal dialog with a registration form inside. 我有一个模式对话框打开,里面有一个表单供用户登录。如果用户尚未注册,则该模态对话框中有一个链接,用于打开另一个带有注册表单的模态对话框。 Problem is that is causing conflict and looks weird. 问题是导致冲突并且看起来很奇怪。 I guess i need to close the login form modal dialog before i open the registration modal dialog. 我想在打开注册模式对话框之前需要关闭登录表单模式对话框。

// 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>

You can open/close the dialog as needed even from within another dialog. 您甚至可以在另一个对话框中根据需要打开/关闭对话框。 Using this style: 使用这种风格:

div.modal {
    display:none;
}

With this html: 有了这个html:

<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>

You can do this in javascript: 你可以在javascript中执行此操作:

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

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

Here's a fiddle . 这是一个小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM