dqjgf0982 2018-08-13 12:04
浏览 80
已采纳

日期选择器:继续下一个选择

I am using a package. Specifically this.

Everything works fine, I clicks on the date picker, I selects year, Then month and then date, And the picker closes.

But when it closes and i click on it again, Only the last day calendar shows, Meaning it doesn't starts over again from year.

What i want is that, It should starts over again from year to month to day.

Here is the JsFiddle

Here is my code :

<div class='input-group date' id='datetimepicker9'>
    <input type='text' class="form-control" />
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
    </span>
</div>

Js :

$(function () {
    $('#datetimepicker9').datetimepicker({
        viewMode: 'years'
    });
});
  • 写回答

1条回答 默认 最新

  • duanhanglekr37902 2018-08-13 12:18
    关注

    From the datetimepicker issue tracker, issue 1897 there is a suggestion for a workaround.

    Basically you add a timeout that resets the datetimepicker to years mode once it's been used once.

    $(function () {
      $('#datetimepicker9').datetimepicker({
        viewMode: 'years'
      });
    
      $('#datetimepicker9').on('dp.hide', function(event){
        setTimeout(function(){
          $('#datetimepicker9').data('DateTimePicker').viewMode('years');
        },1);
      });  
    });
    

    fiddle

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料