javascript - Jquery Bootstrap Modal...如何从另一个模式对话框中打开不同的模式对话框

标签 javascript jquery ajax twitter-bootstrap 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>

最佳答案

您甚至可以在另一个对话框中根据需要打开/关闭对话框。使用这种风格:

div.modal {
    display:none;
}

使用这个 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>

您可以在 JavaScript 中执行此操作:

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

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

这是一个fiddle .

关于javascript - Jquery Bootstrap Modal...如何从另一个模式对话框中打开不同的模式对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21447420/

相关文章:

ajax - 计算 Json 字符串中的重复值并将值和标签存储在另一个字符串中

javascript - 使用 ('click' ) 而不是点击

javascript - 语法错误 : Unexpected identifier in node

javascript - 如何限制将可拖动元素拖放到预定义的 div 元素中?

javascript - Node.js 中 Youtube 数据 API 的批处理

jQuery Mobile 记录所有事件,以修复空白页面

php - 新的 Google ReCaptcha 实现和提交前检查

javascript - jQuery:取消绑定(bind)事件处理程序以稍后再次绑定(bind)它们

javascript - 如何在 PHP 中点击按钮将数据插入数据库时​​增加进度条

javascript - 在 Nuxt.js 中完全呈现路由后运行函数