javascript - Laravel 中的引导日期选择器
问题描述
我使用 Laravel 引导程序和日期选择器,如下所示,这是代码,我已经确保日期格式正确运行,但是 todayHighlight: false 不起作用,容器也不能正常工作
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$('.datepicker_modal').datepicker({
dateFormat: 'dd-mm-yy',
container: $(this).closest('.dateContainer'),
todayHighlight: false
});
});
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button type="button" class="btn btn-success mx-1" data-toggle="modal" data-placement="bottom" title="Approve" data-target="#accept_1">
Click to Show
</button>
<div class="modal fade" id="accept_1" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-accept modal-content">
<div class="modal-header bg-success text-light">
<h5 class="modal-title" id="exampleModalLongTitle"><strong>ACCEPT </strong></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form method="POST" action="">
<div class="modal-body">
<div class="form-group dateContainer">
<label for="date_pick">Date</label>
<input id="date_pick" placeholder="DD-MM-YYYY" type="text" class="form-control datepicker_modal" name="date_pick" autocomplete="off" required>
</div>
</div>
<div class="modal-footer d-flex justify-content-center">
<button type="button" class="btn btn-danger" data-dismiss="modal">CANCEL</button>
<button type="submit" class="btn btn-success">ACCEPT</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
但是在我的 Laravel 项目中,日期选择器是浮动的,并且仍然突出显示当前日期 有什么想法可以解决这个问题吗?
解决方案
添加startDate
你的js:
<script>
$(document).ready(function(){
$('.datepicker_modal').datepicker({
dateFormat: 'dd-mm-yy',
startDate: "12-12-2020",
container:'#myModalId',
todayHighlight: false
});
});
</script>
容器属性可以解决位置:
<input id="date_pick" placeholder="DD-MM-YYYY" type="text" data-date-container='#myModalId' class="form-control datepicker_modal" name="date_pick" autocomplete="off" required>
推荐阅读
- django - 在应用程序启动时预填充组表及其权限的最佳方法是什么?
- django - 从数据库中获取 id 和描述以在 django 中进行下拉
- c++ - 用随机字节填充字节向量
- python - 如何在某些字段更改和剩余重复的情况下创建 DataFrame?
- graphql - 无法通过 Apollo 客户端使用突变删除 Mongo 文档
- git - 当我在 Github 上导入私人仓库时,大文件未正确链接
- vb.net - 为什么当我尝试将对象添加到列表时会出现错误?
- django - 在 Django 数据表中添加行 ID
- sql - SQL 更新库存添加新发票时
- c# - 如何在uwp的scrollviewer中从底部到顶部垂直偏移?