Jump to content

[SOLVED] Blockcategories into a scrolling div - how to autofocus the current category?


Recommended Posts

Hi,

i have many categories and the div.block has a max-height, 'cause i need a scrollbar...

how to autofocus the current selected category position? or better, how to scroll to selected list item? I wouldn't the user to see the block from the beginning if the current category is more to the bottom...

Can you help me please? Thanks

Edited by mmsh (see edit history)
Link to comment
Share on other sites

i have #categories_block_left (with the scrollbar) AND #categories_block_left ul.tree a.selected ...

now, the jquery.scrollTo-1.4.2-min.js is already loaded (isn't it?)

and so, how to scroll from the first to the last with jquery? and where to put the code? thanks

Link to comment
Share on other sites

blockcategories.tpl:

i tried with...

...
<script type="text/javascript">
 // <![CDATA[
  // we hide the tree only if JavaScript is activated
  $('div#categories_block_left ul.dhtml').hide();
 // ]]>
 </script>
 {literal}
 <script type="text/javascript">
 $(document).ready(function () {
$('div#categories_block_left').scrollTo( $('div#categories_block_left ul.tree a.selected'), 1000 )
});
 //OR ul.tree a.selected OR a.selected
 </script>
{/literal}

but it doesn't work... what's wrong? please help

Edited by mmsh (see edit history)
Link to comment
Share on other sites

oh YES... solved!!! hope this helps for someone :D

{literal}
<script type="text/javascript">
  $(document).ready(function () {
var container = $('#categories_block_left'),
scrollTo = $('#categories_block_left ul.tree a.selected');
container.scrollTop(
scrollTo.offset().top - container.offset().top + container.scrollTop()
   );
});
</script>
{/literal}

Edited by mmsh (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...