javascript - 我如何添加关闭按钮并调整 jQuery 模式的大小
问题描述
我有以下 jQuery 模式代码:-
<script>
$(document).ready(function () {
$(function () {
$.ajaxSetup({ cache: false });
//$("a[data-modal]").on("click", function (e) {
$(document).on('click', 'a[data-modal]', function (e) {
$('#myModalContent').css({ "max-height": screen.height * .82, "overflow-y": "auto" }).load(this.href, function () {
$('#myModal').modal({
height: 1000,
width: 2200,
resizable: true,
keyboard: true,
backdrop: 'static',
draggable: true
}, 'show');
});
return false;
});
});
$(function () {
$(document).on('click', 'a[data-dismiss]', function (e) {
if ($(this).attr('data-reload') == 'no') {
$(this).parents('.modal').first().modal('hide');
}
});
});
});
</script>
以及以下 HTML 来显示模式:-
<div id='myModal' class='modal fade in'>
<div class="modal-dialog">
<div class="modal-content">
<div id='myModalContent'></div>
</div>
</div>
</div>
<a data-modal='' href="/home/bookappointment" title="Detail"> Book Appointment </a>
但目前模态只会占据屏幕的很小一部分+我无法关闭模态弹出窗口。那么任何人都可以建议我如何扩展模态高度和宽度+为其添加关闭按钮吗?
解决方案
您可以像这样使用 data-dismiss="modal" 。
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
推荐阅读
- kotlin - 如何解析这种类型的 JSON?
- ssl - 是否可以在没有代理的情况下连接到自定义端口上的安全 websocket?
- openshift - 如何为 KeyCloak 配置 OpenShift 路由器?
- java - 如何解决 java.sql.SQLException:找不到适合 jdbc:derby 的驱动程序:
- bash - 为什么 bash 的行注释技巧不适用于感叹号“!”
- multithreading - 多处理器系统中线程之间的同步如何执行,其中线程共享数据但在不同的处理器中运行
- shopware - 基于实体定义的自动生成迁移 - Shopware 6
- javascript - 如何在一个语句中为右、下和左设置边框样式
- listview - 使用主详细信息页面的导航抽屉列表视图的子菜单
- java - 如何使用不在“查询集合”中的值对 Firestore RecyclerView 项目进行排序?(社会排行榜)