Bootstrap 3 datetimepicker事件未触发 [英] Bootstrap 3 datetimepicker events not firing up

查看:124
本文介绍了Bootstrap 3 datetimepicker事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Bootstrap 3 DateTimePicker ,并且我正在尝试示例8(链接的datetimepicker ).

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

<div class="row">
  <div class="col-md-6 col-sm-6 form-group">
    <label for="txtStartDate">
      Start Date-Time</label>
    <div class="input-group date" id="dpStart" data-date-format="DD-MM-YYYY">
      <asp:TextBox ID="txtStartDate" runat="server" CssClass="form-control"></asp:TextBox>
      <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
      </span>
    </div>
  </div>
  <div class="col-md-6 col-sm-6 form-group">
    <label for="txtEndDate">
      End Date-Time</label>
    <div class="input-group date" id="dpEnd" data-date-format="DD-MM-YYYY">
      <asp:TextBox ID="txtEndDate" runat="server" CssClass="form-control"></asp:TextBox>
      <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
      </span>
    </div>
  </div>
</div>

Calender正在根据需要显示,但是诸如dp.change,dp.hide和dp.show之类的事件没有触发.可能是什么问题?有帮助吗?

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?

请注意,我已经包含了所有必需的文件,例如Bootstrap js,bootstrap css,Moment.js和datetimepicker js和css文件.

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

推荐答案

这似乎很愚蠢,但是您是否检查过是否使用了与问题中所指的相同的bootstrap-datetimepicker.js插件?

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. 您在问题中提供的版本: http://eonasdan.github.io/bootstrap-datetimepicker/
  2. 稍有不同的版本: http://www.eyecon.ro/bootstrap-datepicker/
  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/

第一个版本响应change.dp,而第二个版本响应dp.change.

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

只需查看bootstrap-datetimepicker.js顶部的注释,即可查看正在使用的注释.

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

这篇关于Bootstrap 3 datetimepicker事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆