首页 > 编程开发 > web开发 > BootStrap教程

Select2在Bootstrap 3 Modal框中不能搜索的解决方法

2015-07-25 08:27:57| 发布: | 浏览: 4580

在项目中用了Select2,基于Bootstrap 3的搜索下拉框。但奇怪的是,在modal-dialog中的搜索功能竟不能用。

在网上查有人说在modal中去掉tabindex="-1"



github上说:

Fix z-index for modals

Select2 did not previously have a high enough `z-index` for it to

be displayed over modals. The `z-index` has been raised to 1051,

so now it should appear over the jQuery UI and Bootstrap modals.


解决方案是在js 里加上$.fn.modal.Constructor.prototype.enforceFocus =function(){};


以下是我找到的文章,http://www.pavlatka.cz/2014/04/enable-search-select2-bootstrap-3-modal/

<head>
 <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
 <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
 <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    
 <script type="text/javascript" src="/js/select2/select2.js"></script>
<script type="text/javascript">
 $.fn.modal.Constructor.prototype.enforceFocus = function () {};
 </script>
     
 ....
</head>



如非特别注明,本站内容均为领悟书生原创,转载请务必注明作者和原始出处。
本文地址:http://www.656463.com/bootstrap/JNZNri.htm

相关专题