content disappearing when using jquery slideToggle in IE7
Asked Answered
A

4

6

I've seen this question asked several times but haven't seen any answers.

I have a ul that I'm expanding and collapsing using slideToggle() with jquery. The code is simple:

$('#leftMenu li a.moreLess').click(function() {
    $(this).next().slideToggle('normal');   
});

With markup of:

<a class="moreLess">Click here to see more</a>
<ul>
  <li>something</li>
  <li>something else</li>
  ...
</ul>

I have a button with a class of .moreLess and when it is clicked the list below it should expand or collapse. For some reason in IE 7 all of the content is disappearing once the list is fully expanding. When it collapses, the content appears again until the list is fully closed.

I'm not sure if this is something CSS related, but I was hoping someone might have run into this before. Thanks in advance for your help!

Askew answered 27/7, 2010 at 21:31 Comment(1)
possible duplicate of jQuery slideDown in IE9 - content disappears after animation finishesMaximilien
A
10

FYI the problem was with CSS positioning on the elements inside the UL that is being toggled. Once I removed any relative and/or absolute positioning on those elements, the problem no longer happened.

Askew answered 28/7, 2010 at 18:29 Comment(2)
Thanks a lot for coming back and answering your own question, ran into the exact same problem and this fixed it for me.Waits
Also seems to be an issue when you have postition:relative|absolute for the thing being toggled (not just the contents). In my case it was a div. The fix by Phenom (set zoom:1 property) solved my problem.Riarial
O
19

put a zoom:1 property. it works with position:relative.

Outofdate answered 2/11, 2011 at 9:34 Comment(1)
Worked for me! sometimes IE being so bad is actually a good thing, as there's tons of documentation out there about how to solve it. much better than just being temperamentalIou
A
10

FYI the problem was with CSS positioning on the elements inside the UL that is being toggled. Once I removed any relative and/or absolute positioning on those elements, the problem no longer happened.

Askew answered 28/7, 2010 at 18:29 Comment(2)
Thanks a lot for coming back and answering your own question, ran into the exact same problem and this fixed it for me.Waits
Also seems to be an issue when you have postition:relative|absolute for the thing being toggled (not just the contents). In my case it was a div. The fix by Phenom (set zoom:1 property) solved my problem.Riarial
D
4

put overflow: hidden; for the div in which you have the content, that gets messed up. Works for me, but still it's and IE bug...

Dahlberg answered 15/10, 2012 at 10:42 Comment(0)
M
0

in my case the content loaded with slideToggle was "shifted" down creating 2 empty space (only in IE7)

i solved with this css:

form {
    margin: 0;
}
Marilla answered 14/1, 2013 at 9:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.