简体   繁体   English

如何使用更改事件更改启用日期时间选择器的小时数?

[英]How to change Date Time Picker enabled hours using on change event?

I have the following picker:我有以下选择器:

$('.datetimepicker').datetimepicker({
    format: 'LT',
    locale: 'PT-BR',
    icons: {
      up: "fa fa-chevron-up",
      down: "fa fa-chevron-down",
      time: "far fa-clock",
    },
    enabledHours: permittedHours(),
    stepping: 15,
  });

But I want to call other aux function on re-set the enabledHours case the input value changes.但我想在重新设置 enabledHours 情况下调用其他辅助 function 输入值发生变化。

I chained this and could successfully pop the alert:我链接了它并可以成功弹出警报:

$('.datetimepicker').datetimepicker({
    format: 'LT',
    locale: 'PT-BR',
    icons: {
      up: "fa fa-chevron-up",
      down: "fa fa-chevron-down",
      time: "far fa-clock",
    },
    enabledHours: permittedHours(),
    stepping: 15,
  })
  .on('dp.change', function (e) { 
    alert(e.date._i)
  });

But I if I try to deal with enabledHours it doesn't work.但是如果我尝试处理 enabledHours 它不起作用。 How can I pass a new value to enabledHours in this case?在这种情况下,如何将新值传递给 enabledHours?

on('dp.change', function (e) {
     $('.datetimepicker').data("DateTimePicker").enabledHours(your_function(e.date.format('yourformat')));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM