Bootstrap datepicker无法正常工作 [英] Bootstrap datepicker not working correctly

查看:922
本文介绍了Bootstrap datepicker无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的webapp中,我使用引导组件;在我的一个页面中,我试图放置一个引导的日期戳记,或者更好的一个datetimipicker,仍然没有运气。



我的css和js导入是(按顺序) :




  • bootstrap.css

  • datepicker.css

  • jquery.js

  • bootstrap.js

  • bootstrap-datepicker.js



我正在写的代码是:

 < div class =container> 
< div class =row>
< div class ='col-sm-6'>
< div class =form-group>
< div class ='input-group date'>
< input data-format =dd / MM / yyyy hh:mm:sstype ='text'class =form-controlid ='datetimepicker2'/>
< span class =input-group-addon>< span class =glyphicon glyphicon-calendar>< / span>
< / span>
< / div>
< / div>
< / div>
< script type =text / javascript>
$(document).ready(function(){
$('#datetimepicker2')。datetimepicker();
});
< / script>
< / div>
< / div>

但是我尝试了许多脚本的组合(避免了文档就绪函数调用和调用函数),在div和输入上设置'datetimepicker2'id,总是没有运气。



当我尝试我的datepicker没有任何反应,在控制台我总是得到:


uncaught typeerror undefined不是函数


错误在线:

  $('#datetimepicker2')。datetimepicker(); 

我在网路上搜索过,我不是唯一一个有这个问题的人,很多人解决了将div类放在日期中,但这并没有对我有所裨益。其他人也建议导入jQueryUI,但还是没有运气。任何提示?

解决方案

似乎有一个jquery冲突。 Cehck你的jquery版本和所需的jquery版本的引导datepicker,或者你可以在html页面中导入两个jquery版本。


in my webapp I'm using bootstrap components; in one of my pages I'm trying to put a bootstrap datepicker, or better a datetimepicker, still with no luck.

My css and js imports are (in order):

  • bootstrap.css
  • datepicker.css
  • jquery.js
  • bootstrap.js
  • bootstrap-datepicker.js

The code I'm writing is:

<div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <div class="form-group">
                <div class='input-group date'>
                    <input data-format="dd/MM/yyyy hh:mm:ss" type='text' class="form-control" id='datetimepicker2' />
                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <script type="text/javascript">
        $(document).ready(function() {
                $('#datetimepicker2').datetimepicker();
            });
        </script>
    </div>
</div>

But i tried lot of combinations of the script (avoiding the document ready function call and just calling the function), setting the 'datetimepicker2' id both on div and input, always with no luck.

When I try my datepicker nothing happens, and in the console I always get the:

uncaught typeerror undefined is not a function

error on the line:

$('#datetimepicker2').datetimepicker();

I have searched along the web and I'm not the only one having this problem, lot of people solved putting in the div class the 'date', but that didn't do the trick for me. Other people suggested to import jQueryUI too, but still no luck. Any hint?

解决方案

It seems a jquery conflicts. Cehck your jquery version and required jquery version for bootstrap datepicker, or may be you have imported two jquery versions in html page.

这篇关于Bootstrap datepicker无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆