I have rows of data contained within a scrollable div, and a user can expand a row to show more information if they click on DIV 1 which is contained within each row. DIV 2 which contains more information is then displayed/toggled using jquery.
So my design looks like so:
|- - - - - - -
|Row 1
|Row 2
|Row 3
|Row 4
|etc..
- - - - - - - - -
the segregated lines around my rows is my scrollable div container.
When a user clicks Div 1 this then shows Div2
|- - - - - - - - - - - -
| Row 1
|Div 2 (Now Showing)
|Row 2
|Row 3
|Row 4
- - - - - - - - - - -
as you can see in this example my scrollable container is at the top so div 2 is in view in this instance when the user has clicked on div 1 within row 1. however if a user then clicks on DIV 1 contained within row 4, which would then show div 2 underneath row 4, without the user having to manually scroll down they can not see DIV 2 as it is displayed outside of the scrollable container.
The user would have to manually have to scroll down, which could be exhausting depending on which row they are clicking on.
So my question is, how do I get my DIV2 to always scroll into view to the user?
so in effect what we would have is:
|- - - - - - - - - - - -
| Row 1 <--- User does not scroll the outer container
|Div 2 (Now Showing) up or down.
|Row 2 |
|Row 3 < - - -|
|Row 4 <---- User clicks on DIV 1 within Row 4 without scrolling.
- - - - - - - - - - -
Then...
|- - - - - - - - - - - -
|Row 4 <--- Without the user needing to scroll the
|Div 2 (Now Showing) outer container.
|Row 5 /\ |
|Row 6 | < - - -|
|Row 7 |--- Div 2 automatically scrolls into view.
- - - - - - - - - - -
I'm brand new to jquery so would appreciate it if someone could show me where i'm going wrong, thanks in advance.
<script>
$(".details").click(function()
{
$(this).parent().next('.request_details').toggle();
});
</script>
<script>
$(".request_details").ready(function(){
$("html, body").delay(2000).animate({
scrollTop: $('#search_results').offset().top
}, 2000);
});
</script>