Uncaught TypeError: undefined is not a function jquery.datetimepicker.js:1619(anonymous function)
Uncaught TypeError: undefined is not a function jquery.datetimepicker.js:1619(anonymous function)
我尝试在我的 Symfony 2.7 项目中使用 jquery.datetimepicker 但是当我在我的视图中调用 datetimepicker 时没有加载日期和时间。控制台显示此错误:
Uncaught TypeError: undefined is not a function
jquery.datetimepicker.js:1619(anonymous function)
这是我的代码:
<div class="contact">
<div class="company_address">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.</p>
</div>
<div class="contact-form" >
{{ form(form) }}
<button type="submit" class="cancel" name="cancel" onclick="location.href = '{{ path('assistance_list') }}'">Cancel</button>
</div>
<div class="clear"></div>
<script>
$(document).ready(function () {
$.datetimepicker.setLocale('en');
$("#daiquiri_daiquiribundle_assistance_date input").each(function () {
$(this).attr("readonly", "readonly");
});
$('#daiquiri_daiquiribundle_assistance_date_date').datetimepicker({
format: "Y-m-d",
timepicker: false,
datepicker: true,
theme: 'dark'
});
$('#daiquiri_daiquiribundle_assistance_date_time').datetimepicker({
format: "H:i",
timepicker: true,
datepicker: false,
step: 10,
theme: 'dark'
});
});
</script>
</div>
当您使用您知道的函数名称是 jQuery 方法名称时,返回此错误,代表您 100% 是错字,或者 jQuery 库是没有正确加载。由于文档就绪有效,但此方法无效,因此 jQuery 已正确加载,但 datetimepicker 方法的源库未正确加载。如果您在 chrome 中,请按 F12,然后检查您的资源或控制台。如果您有 link,控制台应该会显示类似 "Failed to load resource" 的内容,但这是不正确的。如果您根本没有加载它,这些插件所需的库在这里:https://jqueryui.com/
抱歉这个问题,这是我尝试加载的错误:
<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.js"></script>
<script src="jquery.datetimepicker.js"></script>
加载时间:
<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.js"></script>
*<script src="jquery.datetimepicker.full.js"></script>*
通过此更改解决了问题。
感谢大家的帮助。
我尝试在我的 Symfony 2.7 项目中使用 jquery.datetimepicker 但是当我在我的视图中调用 datetimepicker 时没有加载日期和时间。控制台显示此错误:
Uncaught TypeError: undefined is not a function jquery.datetimepicker.js:1619(anonymous function)
这是我的代码:
<div class="contact">
<div class="company_address">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.</p>
</div>
<div class="contact-form" >
{{ form(form) }}
<button type="submit" class="cancel" name="cancel" onclick="location.href = '{{ path('assistance_list') }}'">Cancel</button>
</div>
<div class="clear"></div>
<script>
$(document).ready(function () {
$.datetimepicker.setLocale('en');
$("#daiquiri_daiquiribundle_assistance_date input").each(function () {
$(this).attr("readonly", "readonly");
});
$('#daiquiri_daiquiribundle_assistance_date_date').datetimepicker({
format: "Y-m-d",
timepicker: false,
datepicker: true,
theme: 'dark'
});
$('#daiquiri_daiquiribundle_assistance_date_time').datetimepicker({
format: "H:i",
timepicker: true,
datepicker: false,
step: 10,
theme: 'dark'
});
});
</script>
</div>
当您使用您知道的函数名称是 jQuery 方法名称时,返回此错误,代表您 100% 是错字,或者 jQuery 库是没有正确加载。由于文档就绪有效,但此方法无效,因此 jQuery 已正确加载,但 datetimepicker 方法的源库未正确加载。如果您在 chrome 中,请按 F12,然后检查您的资源或控制台。如果您有 link,控制台应该会显示类似 "Failed to load resource" 的内容,但这是不正确的。如果您根本没有加载它,这些插件所需的库在这里:https://jqueryui.com/
抱歉这个问题,这是我尝试加载的错误:
<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.js"></script>
<script src="jquery.datetimepicker.js"></script>
加载时间:
<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.js"></script>
*<script src="jquery.datetimepicker.full.js"></script>*
通过此更改解决了问题。 感谢大家的帮助。