douhuang2218 2018-08-14 18:43
浏览 260
已采纳

Laravel中的Bootstrap datepicker是自动打开的,没有正确加载样式

I have to prepare a form.blade.php for date changing, my problem is with loading styles or something near connected. Here are my files:

_form.blade.php
<div class='form-group'>
                <div class="input-group datepicker">
                    <input type="text" class="form-control">
                    <div class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </div>
                </div>
            </div>

layout.blade.php

<body>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<script>
    $(function () {
        //Date picker
        $('.datepicker').datepicker({
            format: 'yyyy-mm-dd',
        });
        //Date & Time picker
        $('.datetimepicker').datetimepicker({
            format: 'YYYY-MM-DD HH:mm:ss',
        });
    });
</script>
</body>

The problem is that when the class for div in _form file is set to datepicker <div class="input-group datepicker"> the form looks like auto opened: enter image description here And when i change class to datetimepicker it looks as i want (after click calendar icon theres menu to choose the date): enter image description here

I'm a newbie in Laravel so don't be mad at me :) Thank you for all your time and help!

  • 写回答

2条回答 默认 最新

  • ds342222222 2018-08-14 19:07
    关注

    This has nothing to do with Laravel, it seems that styles from your datepicker and datetimepicker plugins (since they are two different plugins) are having conflict, you should have used just one javascript plugin to handle both, or use libraries that don't collapse with others.

    EDIT:

    Actually, your datetimepicker plugin from Eonasdan supports the use of datetime or just date, the format specified in the options defines what components are shown

    $('.datetimepicker').datetimepicker({
                        format: 'MM/dd/YYYY'
                    }
    
    );
    

    please, refer to the documentation:

    http://eonasdan.github.io/bootstrap-datetimepicker/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵