views:

58

answers:

0

HI, I have a problem with jQuery, jScrollPane and loading data with AJAX. When I have static data a div the scrollpane works fine, but as soon as I load data with AJAX in the div the scrollpane disappears.

I know that I have to reinitialise the scrollpane after that, so I am doing this.. but probably wrong as it is not working.

So, the following example works OK when it is loaded, but when I click the home button the scrollbar disappears. Any suggestions?

Code:

<html>
<head>
<title>Title of my page</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link type="text/css" href="jquery/jquery.jscrollpane.css" rel="stylesheet" media="all" />
<script src="jquery/jquery-1.4.2.min.js"></script>

<!-- the jScrollPane script -->
<script type="text/javascript" src="jquery/jquery.jscrollpane.min.js"></script></head>
<body style="background-color: black;">
<div style="background-image: url(test.jpg);background-repeat: no-repeat;  width: 1024px; height: 768px; margin-left: auto; margin-right: auto;">
    <div id="menu">
        <script type="text/javascript">
        $(document).ready(function(){

                        reinitialiseScrollPane = function()
            {
                $('#contents').jScrollPane();

            }

            $("#home").click(function(){ $("#contents").load("lorem.php", '', reinitialiseScrollPane); });


                        $("#contents").jScrollPane();   

        });
        </script>
        <a id="home"><span>Home</span></a>

    </div>
    <div id="website">
        <div id="contents" name="contents">

        </div>

    </div>
</div>
</body>