【发布时间】:2014-04-22 17:48:45
【问题描述】:
我正在使用https://github.com/jonthornton/jquery-datepair。
我想在 MVC 应用程序中使用 datepair 示例,但遇到 javascript 错误。
脚本抛出错误:'undefined is not a function'
我做错了什么?
这是我的代码。
查看:
<p id="basicExample">
<input type="text" class="date start" />
<input type="text" class="time start" /> to
<input type="text" class="time end" />
<input type="text" class="date end" />`enter code here`
</p>
脚本:
$(function () {
$('#basicExample .time').timepicker({
'showDuration': true,
'timeFormat': 'g:ia'
});
$('#basicExample .date').datepicker({
'format': 'm/d/yyyy',
'autoclose': true
});
// initialize datepair
$('#basicExample').datepair();
});
【问题讨论】:
-
出于某种原因,我原来的帖子删除了脚本标签。我在参考。 jquery.datepair.js, jquery-2.1.0.js, jquery-ui-1.10.4.js(这是用于日期选择器的), jquery.timePicker.js
-
检查你的 jquery.js 是否高于其他 js。或
$(document).ready(function(){}; -
我相信 jquery.js 是最新版本。这样,timepicker.js 就无法正常工作。但是,根据github.com/jonthornton/jquery-datepair 文档,datepair.js 可以在没有时间选择器的情况下工作。如果我删除 timepicker.js,我仍然会收到该错误。
-
我的意思是你放置 .js 文件的顺序,jquery 总是第一个。例如
<script src="jquery.js"/><script src="other.js"/> -
我认为问题来自
$(function () {并替换$(document).ready(function(){ //your code here });
标签: javascript jquery jquery-plugins