Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fail to open at first in IE7 and 8 #369

Closed
dgiebe opened this Issue · 5 comments

4 participants

@dgiebe

Hi,

I use select2 in my project and have an issue with open them at first click. In IE7 and 8 its not properly opening. At first click to open it, it just doesnt do anything and on second click its opened correctly. Sometimes its opened at first click but then there is a z-index issue and its beneath all other elements. So somehow it seems to be doing a random failures.

After 1st click:

http://d.pr/i/s0kS

After 2nd click:

http://d.pr/i/jjFv

Does anyone have an idea how to solve that?

Thanks a lot.

@ivaynberg
Owner

please create a jsfiddle that reproduces this problem

@am0d

I came across this same issue, on some forms which are somewhat smaller (but still large enough for the drop down to display). I traced through the code a bit, and found that this is caused by Select2 trying to .scrollTo the selected or first element in the drop down. Doing this seems to trigger a resize event on IE8, which is handled before the drop down is open fully. This causes it to close, but not completely, and therefore I was seeing the search box but nothing else opens until I click again.

@mhamel

The select2 need to be at the bottom to be able to reproduce the problem.

If I comment the $(window).bind into the opening function, the problem disappear but the select2 not closing on resize anymore.

So, a possible workaround for IE8:
window.setTimeout(function () {
$(window).bind(resize, function () {
var s2 = $(selector);
if (s2.length == 0) {
$(window).unbind(resize);
}
s2.select2("close");
});
},500);

@dgiebe

Thanks so far. What do you mean with: select2 needs to be at the bottom? Last loaded file in css and js?

@mhamel

Select2 should be at the bottom of the page visually

@ivaynberg ivaynberg closed this in 96657a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.