当同一页面中有多个时间选择器时,我注意到一个奇怪的行为。 在两个时间选择器之间切换后,最终其中一个不会被删除/隐藏,并且将持续存在,直到我们刷新页面。
我认为这是我的代码的问题,但后来我用我在谷歌上找到的一个简单的 Bootstrap 示例进行了测试。
fiddle 错误示例: http://jsfiddle.net/kW3G7/282/
使用的唯一代码是:
`$('.timepicker').timepicker();
提前致谢。
编辑:我创建了一个 issue在 github 项目中
编辑2:时间选择器似乎停止调用文档onclick事件(上面的代码)
$(document).on('mousedown.timepicker, touchend.timepicker', function (e) {
// This condition was inspired by bootstrap-datepicker.
// The element the timepicker is invoked on is the input but it has a sibling for addon/button.
if (!(self.$element.parent().find(e.target).length ||
self.$widget.is(e.target) ||
self.$widget.find(e.target).length)) {
self.hideWidget();
}
});
最佳答案
解决方案,目前,从“on”事件触发器中删除“touchend.timepicker
”。
我认为这不是正确/最终的解决方案,但它似乎可以工作。
关于javascript - 同一页面中存在多个时间选择器的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26284187/