jsTree display flaw in IE8

2019-02-24 23:15发布

问题:

I've been working with jsTree and encountered a problem in IE8. All the data is displayed correctly in the tree, but when I attempt to collapse a branch of the tree it does not display properly. That is, the smooth collapse animation happens, but then the data is again visible when it should not be.

The same code works great on Firefox 3.6.27 and Chrome 18.0.1025.151. Any idea why IE8 would behave differently?

Here is the code for the webpage:

<html>
<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jstree/jquery.jstree.js"></script>
</head>
<body style="margin:0px">
    <script type="text/javascript">
        $(function() {
            $("#equipment_tree")
                .jstree({ "plugins" : ["themes","html_data","ui"] });
        });
    </script>
    <div id="equipment_tree" style="width:185px; float:left; height:100%; overflow:auto;">
        <ul>
            <li class="jstree-open"><a href="#">Root node 1</a>
                <ul>
                    <li><a href="#">Child node 1</a></li>
                    <li><a href="#">Child node 2</a></li>
                    <li><a href="#">Child node 3</a></li>
                    <li><a href="#">Child node 4</a></li>
                </ul></li>
            <li><a href="#">Root node 2</a></li>
        </ul>
    </div>
</body>
</html>

And also a picture of the erroneous behavior:

回答1:

You are missing the !DOCTYPE declaration. Add the following to the top of your page and that should fix the problem...

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Read here about !DOCTYPE for IE.



回答2:

This is perfect.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">