Bootstrap 3 datetimepicker事件未触发

writeToBhuwan:

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

Java脚本

$('#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>

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

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

itsmejodie:

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

我知道有两个版本非常相似:

  1. 您在问题中提供的版本:http : //eonasdan.github.io/bootstrap-datetimepicker/
  2. 稍有不同的版本:http : //www.eyecon.ro/bootstrap-datepicker/

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

只需查看顶部的评论,bootstrap-datetimepicker.js即可查看正在使用的评论。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章