我尝试在我的Symfony 2.7项目中使用jquery.datetimepicker但是当我在视图中调用datetimepicker时没有加载日期和时间。控制台显示此错误:
未捕获的TypeError:undefined不是函数 jquery.datetimepicker.js:1619(匿名函数)
这是我的代码:
<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>
答案 0 :(得分:0)
当您使用所述函数名称时,您知道它是一个jQuery方法名称,并且返回此错误,它代表您100%拼写错误,或者未正确加载jQuery库。由于文档准备就绪,但不是这种方法,即jQuery正确加载,而不是datetimepicker方法的源库。如果您使用chrome,请按F12,然后检查您的资源或控制台。控制台应该说&#34;无法加载资源&#34;如果你有一个链接,但它是不正确的。如果您还没有加载它,那么这些插件所需的库位于:https://jqueryui.com/
答案 1 :(得分:0)
对不起这个问题,我正在尝试加载错误:
<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>*
通过这种改变解决了这个问题。 感谢大家的帮助。