Bootstrap 3 datetimepicker events not firing up

匿名 (未验证) 提交于 2019-12-03 01:13:01

问题:

I am using Bootstrap 3 DateTimePicker and I am trying example 8 (Linked datetimepicker).

Javascript

$('#dpStart').datetimepicker({      pickDate: true,                 //en/disables the date picker      pickTime: false,      format: "DD-MM-YYYY",      useMinutes: false,               //en/disables the minutes picker      useSeconds: false });  $('#dpEnd').datetimepicker({      pickDate: true,                 //en/disables the date picker      pickTime: false,      format: "DD-MM-YYYY",      useMinutes: false,               //en/disables the minutes picker      useSeconds: false });  $("#dpStart").on("dp.change", function(e) {      alert('hey');      $('#dpEnd').data("DateTimePicker").setMinDate(e.date); });  $("#dpEnd").on("dp.change", function(e) {      $('#dpStart').data("DateTimePicker").setMaxDate(e.date); }); 

HTML

Calender is showing as per the needs but the events like dp.change, dp.hide, dp.show are not firing up.. What could be the problem? Any help?

EDIT: Please note that I've included all necessary files like Bootstrap js, bootstrap css, Moment.js and datetimepicker js and css files.

回答1:

This may seem silly, but did you check you're using the same bootstrap-datetimepicker.js plugin that you're referring to in your question?

There are two versions I know of which are very similar:

  1. The version you provided in your question: http://eonasdan.github.io/bootstrap-datetimepicker/
  2. A slightly different version: http://www.eyecon.ro/bootstrap-datepicker/

The first version responds to change.dp, while the second version responds to dp.change.

Just check the comments at the top of the bootstrap-datetimepicker.js to see which one you're using.



回答2:

Check if you are loading moment.js before loading datetimepicker.js



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!