Bootstrap Timepicker not displaying

2019-08-07 17:13发布

I have a modal window where I have a table where the user can choose times. I was able to get the timepicker to work inside the tables in this example.

$('.timepicker').timepicker().on('changeDate', function(ev){
         $('.timepicker').timepicker('hide');
         });

However, in this example the timepicker is not displaying. There are no exceptions being thrown.

3条回答
虎瘦雄心在
2楼-- · 2019-08-07 18:04

For future reference, you can edit this part on its css:

.bootstrap-timepicker-widget.dropdown-menu.open {
   display: inline-block;
   z-index: 10000;
}
查看更多
Emotional °昔
3楼-- · 2019-08-07 18:11

I ended up going with a jquery plugin which worked right out of the box for selecting the times.

HTML

<label><input id="mondayStartTime" type="text" style="width:100px" data-bind="value: mondayStartTime" class="time ui-timepicker-input"></input>Start</label>
<label><input id="mondayEndTime" type="text" style="width:100px" data-bind="value: mondayEndTime" class="time ui-timepicker-input"></input>End</label>

Javascript

$('#mondayStartTime').timepicker();
$('#mondayEndTime').timepicker();

Available via CDN.

It works well inside the modal dialog.

Here is an example:

http://jsfiddle.net/jkittell/C8w8v/126/

查看更多
孤傲高冷的网名
4楼-- · 2019-08-07 18:11

Replace this code with line #666 in bootstrap-timepicker.js file. It's work for me. This takes current modal z-index value and increase it with 10.

      var index_highest = 0;
      $(".modal").each(function() {
            // always use a radix when using parseInt
            var index_current = parseInt($(this).css("zIndex"), 10);
            if (index_current > index_highest) {
                index_highest = index_current;
            }
        });     
      var zIndex = parseInt(this.$element.parents().filter(function() { return $(this).css('z-index') !== 'auto'; }).first().css('z-index'), 10) + index_highest;
查看更多
登录 后发表回答