如何使用引导程序显示模式对话框
How to show a modal dialog using bootstrap
早些时候,我使用jquery对话框来显示弹出消息。然而,我需要在我的项目中使用boostarp,我无法找到一种实际显示弹出窗口的方法。我在jquery对话框中使用的代码:
showUserWarningMessage: function (title, message, callback, scope, username) {
var $dialog = $("#dialog-move-user-warning");
$dialog.dialog({
resizable: false,
height: 450,
width: 580,
modal: true,
top: 200,
dialogClass: "warning-dialog",
title: title,
position: ["center", 200],
open: function () {
$dialog.find(".btn-default").on("click", function () {
$dialog.dialog("close");
});
$dialog.find(".btn-primary").on("click", function () {
$dialog.dialog("close");
if (callback) {
if (scope) {
callback.call(scope);
} else {
callback();
}
}
});
},
他为引导模式编写了代码:
showAlertMessage: function(options) {
var $dialog = $("#dialog-move-user-warning");
$dialog.modal("show");
}
HTML:
<div class="modal fade" id="dialog-move-user-warning" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">User Info</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
由于某种原因,它没有在屏幕上显示任何内容,尽管背景被禁用,好像弹出了一个覆盖,但可以看到它。我尝试更改class="modal"
的默认设置,但没有帮助。我做错了什么,或者覆盖显示所需的任何其他内容?有什么css
需要我换吗?提前感谢!
以下是使用引导打开模式对话框的多种方法
方法1:使用javascript 打开模式窗口
$("#myModal").modal('show');
方法2:
<button (click)="deleteStudent(item.student_id)" class='btn btn-danger'>Delete</button>
方法3:
<button class='btn btn-success' data-toggle="modal" data-target="#myModalMore">Open</button>
方法4:
<button href="#mypop" class="btn btn-success" data-backdrop="false" data-toggle="modal">Open Modal</button>
<div id="mypop" class="modal fade">
//modal code here
</div>
如果您想使用Bootstrap显示模态,为什么不使用Bootstrap?
1.将模态html添加到页面中
您提供的模态html是有效的,如果您不确定,您可以在这里找到确切的代码和更多示例:http://getbootstrap.com/javascript/#modals-示例
2.在页面中添加触发器
数据目标应该等于您的模态ID,在您的情况下,它是#对话框移动用户警告。
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
3.确保您的网站上包含bootstrap.js和bootstrap.css
Bootstrap模式在很大程度上依赖于Bootstrap.js。你不需要所有东西,你在下面的JSFiddle中找到的就足够了。
http://jsfiddle.net/fgxmcnd2/3/
相关文章:
- 打开相对于鼠标位置的CSS3/HTML5模式对话框
- Bootstrap在页面加载缓慢时会立即显示隐藏的模式对话框
- jQuery UI模式对话框覆盖淡出
- 使用Plaid Link显示自定义用户名和密码模式对话框
- 弹出格式化的模式对话框,并在用户确认时转发
- NProgress带有模式对话框以防止点击
- 使用ember模式对话框的ember中的可路由模式
- 如何在 ember.js 中的模式对话框中打开路由
- 将值从模式对话框传递给父级
- 关闭模式对话框而不刷新父级
- 如何在 javascript 中检测引导模式对话框的关闭
- 将参数传递到模式对话框
- 确认删除的模式对话框
- 当我打开模式对话框时,可以看到2个滚动条
- 用于登录/注册Angular应用程序的模式/对话框
- 选中的单选按钮在jQuery模式对话框中不能正常工作
- Safari限制?使用多种方法来显示多个自定义模式对话框
- 如何将事件绑定到模式对话框上的组件
- 单击按钮打开窗口作为使用javascript的模式对话框
- 用JavaScript制作一个按钮的动画,从按钮到屏幕中心弹出一个模式对话框