cant find the proper event for input field with ti

2019-08-29 10:09发布

问题:

I have an input field with timepicker I used bootstrap calendar for my UI and have this config for timepicker purpose:

   <div class='input-append' id='datetimepicker2' >
            <input data-format='HH:mm:ss PP' type='text' name="start_time" id="start_time" value="<?php echo set_value('start_time')?>"/>
            <span class='add-on'>
              <i data-date-icon='icon-calendar' data-time-icon='icon-time'>
              </i>
            </span>
          </div>
        </div>
        <script type='text/javascript'>
          $(function() {
            $('#datetimepicker2').datetimepicker({
              language: 'en',
              pick12HourFormat: true,
              pickDate: false
            });

          });

        </script>

what im working is that if I'm done entering data using the timepicker from start_time to end_time I automatically calculate the total_time but I dont know where to fire the event. I could'nt use onchange ,onblur because the focus is NOT on the input field but on the timepicker icon. It's not working either when i use $('#datetimepicker2').click or any event in the timepicker, just the $('#datetimepicker2').datetimepicker itself works. So where do i put the event or what specific event do i needed to do that? any help? coz i'm really stuck in here for so long

回答1:

Try using changeDate event.

$('#datetimepicker2').datepicker()
  .on('changeDate', function(ev){

  });