Javascript 日期选择器和 Laravel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43008675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Datepicker and Laravel
提问by rooot_999
I'm trying to add a datepicker to my form and it drives me crazy, I tried everything I know, I've search for hours and all I got is nothing so first here is my blade code:
我试图在我的表单中添加一个日期选择器,它让我发疯,我尝试了我知道的一切,我已经搜索了几个小时,但我得到的只是一无所有,所以首先是我的刀片代码:
<div class="form-group">
{{ Form::label('date', 'Date:') }}
{{ Form::text('date', $payment->date, array('class' => 'datepicker','id' => 'datepicker')) }}
</div>
<script type="text/javascript">
$(function () {
$( "#datepicker" ).datepicker({
todayHighlight: true,
autoclose: true,
});
});
</script>
Second here is a picture that show us the white long space that I wont to remove.
其次是一张图片,向我们展示了我不会删除的白色长空间。
I tried to edit the css file but as far as I get that the css file has nothing to do with this problem.. so please guys help me.
我试图编辑 css 文件,但据我所知,css 文件与这个问题无关..所以请大家帮帮我。
采纳答案by rooot_999
so here is the fix for this problem guys:
所以这是解决这个问题的家伙:
$( "#datepicker" ).datepicker({
format: "mm/dd/yy",
weekStart: 0,
calendarWeeks: true,
autoclose: true,
todayHighlight: true,
rtl: true,
orientation: "auto"
});
the key is the ("dir") code thank you.
关键是(“dir”)代码谢谢。
回答by lewis4u
This is how i use that datepicker with bootstrap:
这就是我如何在引导程序中使用该日期选择器:
<link href="/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
{!! Form::label('date', 'Date: ' ) !!}
<div class="form-group input-group date">
{!! Form::text('date', null, ['class' => 'form-control']) !!}
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<script src="/js/moment.min.js"></script>
<script src="/js/bootstrap-datetimepicker.min.js"></script>
<script>
$function(){
$(.date).datetimepicker({
});
</script>
Maybe you are using wrong datetimepicker. This is the one i am using:
也许您使用了错误的日期时间选择器。这是我正在使用的一个:


