Twitter bootstrap 在引导模式中的日期选择器中选择月份';我不能在Firefox中工作
如果在引导模式中,datepicker中的月份选择在FireFox中不起作用Twitter bootstrap 在引导模式中的日期选择器中选择月份';我不能在Firefox中工作,twitter-bootstrap,jquery-ui-datepicker,bootstrap-modal,Twitter Bootstrap,Jquery Ui Datepicker,Bootstrap Modal,如果在引导模式中,datepicker中的月份选择在FireFox中不起作用 <button class="btn" id="btn">Click Me</button> <div class="modal hide" id="modal" tabindex="-1"> <div class="modal-body"> <input type="text" id="datepicker" />
<button class="btn" id="btn">Click Me</button>
<div class="modal hide" id="modal" tabindex="-1">
<div class="modal-body">
<input type="text" id="datepicker" />
</div>
</div>
以下是一个缩小的示例:
我发现了一个类似twitter引导github的问题:我找到了两个修复此错误的方法: 修复1:如果删除div.modal中的tabindex attr,则月份选择功能正常。 这个解决方案的唯一问题是,在IE(任何版本)上,您仍然需要双击月份下拉菜单才能打开它 Fix2:您可以在以下位置找到第二种解决方案:通过覆盖中提出的enforceFocus函数,您可以再次使用月份下拉列表
$('#modal').on('show', function () {
$.fn.modal.Constructor.prototype.enforceFocus = function () { };
});
我认为第二个是最好的。我也有同样的问题,但那是因为我在输入框上有填充物。一旦拆下它,就可以修复一切。这让我觉得我讨厌Firefox,尽管这是我的错P
首先尝试仅检测firefox浏览器
if(navigator.userAgent.toLowerCase().indexOf('firefox')!=-1){
$.fn.modal.Constructor.prototype.enforceFocus=function(){};
}
Second fix为我做了这件事。在最近的引导版本中,事件可能已经发生了变化,因为我不得不使用:$(“#modal”).on('show.bs.modal'…
你这个摇滚人。第二个修复为我做了。我搜索了很长时间。非常感谢。因为,引导3我们需要使用$('#modal')。on('show.bs.modal',function(){})
,而不是$('#modal').on('show',function(){});
$('#modal').on('show', function () {
$.fn.modal.Constructor.prototype.enforceFocus = function () { };
});