소스 검색

fix for dropdown closing as soon as its opened in IE8. fixes #369. fixes #354

Igor Vaynberg 12 년 전
부모
커밋
96657a16aa
1개의 변경된 파일12개의 추가작업 그리고 7개의 파일을 삭제
  1. 12 7
      select2.js

+ 12 - 7
select2.js

@@ -972,13 +972,18 @@
                 });
             });
 
-            $(window).bind(resize, function() {
-                var s2 = $(selector);
-                if (s2.length == 0) {
-                    $(window).unbind(resize);
-                }
-                s2.select2("close");
-            });
+            window.setTimeout(function() {
+                // this is done inside a timeout because IE will sometimes fire a resize event while opening
+                // the dropdown and that causes this handler to immediately close it. this way the dropdown
+                // has a chance to fully open before we start listening to resize events
+                $(window).bind(resize, function() {
+                    var s2 = $(selector);
+                    if (s2.length == 0) {
+                        $(window).unbind(resize);
+                    }
+                    s2.select2("close");
+                })
+            }, 10);
 
             this.clearDropdownAlignmentPreference();