0

In IE8 the toggle kinda works but it overlays the content below. It works fine in all the other browsers. I've been trying for the past 2 hours to fix this but no luck...

Here's what I mean

jquery:

$(document).ready(function() {  

    $('.toggle').hide();

    $('.expand-all').click(function(){
        // switch visibility
        $(this).data('is_visible', !$(this).data('is_visible'));

        // change the link depending on whether the element is shown or hidden
        $(this).html( (!$(this).data('is_visible')) ? 'Expand all' : 'Hide');

        $(this).next().toggle();

    return false;
    }); 


});

html:

    <div id="categories">
        <div class="cat">
            <h3>Rice</h3>
            <ul>
                <li><a href="">Rice brand 1</a></li>
                <li><a href="">Rice brand 2</a></li>
                <li class="expand-all">Expand all</li>
                <div class="toggle">
                    <li><a href="">Rice brand 1</a></li>
                    <li><a href="">Rice brand 1</a></li>
                </div>
            </ul>
        </div>
        <div class="cat">etc</div>
        <div class="cat">etc</div>
        <div class="cat">etc</div>
    </div>
4
  • The javascript console for that example page is indicating that jquery isn't being loaded. The url for your JS resource is 'tangola1.local'. Commented Jan 11, 2012 at 20:34
  • sorry about that, the jquery file was loaded locally. it should work in chrome/firefox now
    – Cris
    Commented Jan 11, 2012 at 20:37
  • Works fine for me in IE8. Perhaps you should describe what problem you are seeing. Commented Jan 11, 2012 at 20:39
  • For me it works fine in IE8. It stops working when you enter quirks mode. And also IE7 will not work Commented Jan 11, 2012 at 20:41

1 Answer 1

1

It appears as though you are having an issue with the display : inline-block property you are setting.

Here is something to try, for more things to try just Google "internet explorer 8 inline-block": http://www.compsoft.co.uk/Blog/2009/11/inline-block-not-quite-inline-blocking.html

Also IE7 will not accept the display : inline-block property, so you need to add this to your code to make it work in IE7 as well:

.some-ele {
    display  : inline-block;
    *display : inline;
    zoom     : 1;
}

The *display property is invalid but will still be read by IE7 and for it to take affect the element must have the hasLayout property which you can't set manually but you can force it to be set by setting zoom : 1.

For IE6 you need to specify a height for display : inline-block to work but if you only want to specify a height for IE6 you can use _height : XXpx which will only be read by IE6 (more invalid code that IE will digest). Here is some info on this: http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

3
  • sorry about that, the jquery file was loaded locally. it should work in chrome/firefox now. The IE8 still doesn't work.
    – Cris
    Commented Jan 11, 2012 at 20:38
  • In IE8 the toggles work, but they sometimes overlay the content below. Is that what you mean to fix?
    – Jasper
    Commented Jan 11, 2012 at 20:39
  • I'm not sure why the layout isn't being updated when you click the expand links but I added a little bit about backwards compatibility for display : inline-block that you might find useful.
    – Jasper
    Commented Jan 11, 2012 at 20:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.