I have a div that scrolls (there are no scroll bars on the main page) and jQuery UI Button in scrollable content. In IE6 and IE7, the button does not scroll with the contents of the div, and this causes funny things if you hover over it when it is not in the correct position.
Here's an example (jQuery 1.5 is included in the header):
<link rel="stylesheet" type="text/css" href="Lib/jquery-ui-1.8.10.custom.min.css" /> <script type="text/javascript" src="Lib/jquery-1.5.min.js"></script> <script type="text/javascript" src="Lib/jquery-ui-1.8.10.custom.min.js"></script> <div style="width: 400px; height: 300px; overflow: scroll;"> <div style="width: 400px; height: 1200px;"> Hello world<br /><br /> <a href='#' id='test'>test button</a> </div> </div> <script> $('#test').button(); </script>
I found a workaround, but it is not perfect; I catch the scroll event and call .button('enable') on the button element (for some reason .button('refresh') did nothing). This does the scroll button correctly, but now the button appears outside the div when scrolling (it scrolls at the top of the top of the div and is still visible). Here is the code:
<link rel="stylesheet" type="text/css" href="Lib/jquery-ui-1.8.10.custom.min.css" /> <script type="text/javascript" src="Lib/jquery-1.5.min.js"></script> <script type="text/javascript" src="Lib/jquery-ui-1.8.10.custom.min.js"></script> <div class='scrollingDiv' style="width: 400px; height: 300px; overflow: scroll;"> <div style="width: 400px; height: 1200px;"> Hello world<br /><br /> <a href='#' id='test' class='scrollingButton'>test button</a> </div> </div> <script type="text/javascript"> $(function(){ $('#test').button(); $('.scrollingDiv').scroll(function() { $('.scrollingButton').button('enable'); }); }); </script>
source share