twitter-bootstrap 未捕获的类型错误:未定义不是日期选择器引导程序的函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24757515/
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
Uncaught TypeError: undefined is not a function for date picker bootstrap
提问by John Jerrby
I wanted to use datepicker of bootstrap,what I use this code I got error
我想使用bootstrap 的日期选择器,我使用此代码时出现错误
Uncaught TypeError: undefined is not a function Create:283
(anonymous function) Create:283
n.Callbacks.j jquery-2.1.1.min.js:2
n.Callbacks.k.fireWith jquery-2.1.1.min.js:2
n.extend.ready
In this code which having the error,I took it from bootstrap site as-is...
在此有错误的代码中,我按原样从引导站点获取了它...
<script type="text/javascript">
$(function () {
$('#datetimepicker4').datepicker({
});
});
</script>
this is the Div
这是 Div
<div class="well">
<div id="datetimepicker4" class="input-append">
<input data-format="yyyy-MM-dd" type="text" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
</div>
This is the libaray which I use and it doesnt help. I try to add them one by one to see if this problem is solving but not ,any clue?
这是我使用的 libaray,它没有帮助。我试着一一添加,看看这个问题是否正在解决,但没有,任何线索?
<script src="~/Scripts/jquery-2.1.1.min.js"></script>
<script src="~/Scripts/bootstrap-datepicker.js"></script>
<script src="~/Scripts/moment-datepicker.js"></script>
<script src="~/Scripts/moment.min.js"></script>
<script src="~/Scripts/moment.js"></script>
<link href="~/Content/bootstrap-datepicker.css" rel="stylesheet" />
<link href="~/Content/bootstrap-datepicker3.css" rel="stylesheet" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/moment-datepicker/datepicker.css" rel="stylesheet" />
<script type="text/javascript" src="../../Scripts/Create.js"></script>
采纳答案by bbbutch
Try adding class dateto the <div>tag
尝试将类添加date到<div>标签
<div class="well">
<div class="input-append date"> // additional class name
<input data-format="yyyy-MM-dd" type="text" id="datetimepicker4" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
From the documentation
从文档
Adding the date class to an input-append or input-prepend bootstrap component will allow the add-on elements to trigger the picker.
将日期类添加到 input-append 或 input-prepend bootstrap 组件将允许附加元素触发选择器。
回答by yarpi87
Had same problem, in my case it was fact taht I have included bootstrap-datepicker.js earlier than bootstrap.min.js . After moving bootstrap-datepicker.js to footer - everything goes fine.
有同样的问题,在我的情况下,我在 bootstrap.min.js 之前包含了 bootstrap-datepicker.js 是事实。将 bootstrap-datepicker.js 移至页脚后 - 一切正常。
回答by bbbutch
change your code to:
将您的代码更改为:
<div class="well">
<div class="input-append">
<input data-format="yyyy-MM-dd" type="text" id="datetimepicker4" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
</div>
that should do the trick.
这应该够了吧。

