Skip to content

Commit 96657a1

Browse files
committed
fix for dropdown closing as soon as its opened in IE8. fixes select2#369. fixes select2#354
1 parent b4371aa commit 96657a1

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

select2.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -972,13 +972,18 @@
972972
});
973973
});
974974

975-
$(window).bind(resize, function() {
976-
var s2 = $(selector);
977-
if (s2.length == 0) {
978-
$(window).unbind(resize);
979-
}
980-
s2.select2("close");
981-
});
975+
window.setTimeout(function() {
976+
// this is done inside a timeout because IE will sometimes fire a resize event while opening
977+
// the dropdown and that causes this handler to immediately close it. this way the dropdown
978+
// has a chance to fully open before we start listening to resize events
979+
$(window).bind(resize, function() {
980+
var s2 = $(selector);
981+
if (s2.length == 0) {
982+
$(window).unbind(resize);
983+
}
984+
s2.select2("close");
985+
})
986+
}, 10);
982987

983988
this.clearDropdownAlignmentPreference();
984989

0 commit comments

Comments
 (0)