views:

390

answers:

2

I'm using jQuery to display a tabbed area, and I have a table below the tabs. The whole thing, tabs and table, are re-sizable.

I'd like for the table to have a scroll bar, so that when you re-size the container, the scroll bar re-sizes.

Right now, I have two issues.

1) I'd like for the scroll bar to extend from just below the tabs, to the bottom of the tab container object. I'd like for that to be dynamic as the user re-sizes the window. But I can't keep the bottom of my scroll bar exactly above the bottom of my container

2) The entire container (tabs and table) are draggable. But this seems to disable the dragging of the scroll bar (so you can't drag the scroll-"elevator".. you have to click on the arrows or the "elevator shaft" of the scroll bar, to move it. I tried 'handle' parameter in jQuery and couldn't get it to work.

To be thorough, I've included all code so that you can reproduce the problem. Open this .htm file, and try stretching the window and try working the scroller, and you'll see my issues. stretching the window big makes the scroller pull far away from the bottom of the container.

Any attempts to help are much appreciated!

Edit--> I see now that my attempts to display the scrollable area have disabled the "click on the tab" function. So the code below actually has THREE problems - you can't click on the tab and get any action. (with one tab, if you click on it, the content should hide. apparently my overlaying of divs has broken that functionality!)

<html><head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/cupertino/jquery-ui.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"&gt;
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"&gt;
</script>


<style type="text/css">
#grid-tabs {
    width: 720px;
    overflow-x: hidden;
    overflow-y: hidden;
    height: 185px;
}
.outer-container{
    height:         100%;
    position:       relative;
    top:            -45px;
}
.filler{
    height:         60px;
    position:       relative;
    top:            -60px;
}
.inner-container{
    height:         auto;
    overflow-y:     scroll;
    position:       relative;
    top:            -15px;
}
.scroll-area{
    height:         70%;
    position:       relative;
    top:            0px;
}
table{
    border:1px solid #62bbe8;
}
td {
    width: 50px;
}

</style>
</head><body>

<div id='grid-tabs'>
    <ul>
    </ul>

    <div class='outer-container'>
        <div class='filler'>
        </div>
        <div class='inner-container'>
            <div class='scroll-area'>
            <table class='content'>
                <tbody>
                    <tr><td>1.1</td><td>1.2</td><td>1.3</td></tr>
                    <tr><td>2.1</td><td>2.2</td><td>2.3</td></tr>
                    <tr><td>3.1</td><td>3.2</td><td>3.3</td></tr>
                    <tr><td>4.1</td><td>4.2</td><td>4.3</td></tr>
                    <tr><td>5.1</td><td>5.2</td><td>5.3</td></tr>
                    <tr><td>6.1</td><td>6.2</td><td>6.3</td></tr>
                    <tr><td>7.1</td><td>7.2</td><td>7.3</td></tr>
                    <tr><td>8.1</td><td>8.2</td><td>8.3</td></tr>
                    <tr><td>9.1</td><td>9.2</td><td>9.3</td></tr>
                    <tr><td>A.1</td><td>A.2</td><td>A.3</td></tr>
                    <tr><td>B.1</td><td>B.2</td><td>B.3</td></tr>
                    <tr><td>C.1</td><td>C.2</td><td>C.3</td></tr>
                </tbody>
            </table>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    jQuery('#grid-tabs').tabs({collapsible:true}).draggable().resizable();
    jQuery('#grid-tabs').tabs('add','#grid-tabs-1',"Tab 1");

</script>
</body>
+2  A: 

OK, I'm answering my own question.

I was able to address the three issues, and come up with a draggable tab area with a scroll bar that resized correctly.

Here's the final code.   See it in action at JS Bin.

Note the magic, contained in this line:

        jQuery('#grid-tabs').tabs({collapsible:true})
            .draggable({handle:'ul'})
            .resizable({alsoResize:'.container'});

alsoResize! that's the trick. And making "ul"s be my handle (which means that it can be dragged by the tab section), now the scroll bar is functional.

Perfect! Hope this helps someone...

    <html><head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/cupertino/jquery-ui.css" type="text/css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"&gt;
    </script>
    <script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"&gt;
    </script>


    <style type="text/css">
    #grid-tabs {
        width: 720px;
        overflow-x: hidden;
        overflow-y: hidden;
        height: 185px;
    }
    .container{
        height:         auto;
        overflow-y:     scroll;
        position:       relative;
        top:            0px; /* changed */
    }
    .scroll-area{
        height:         70%;
        position:       relative;
        top:            0px;
    }
    table{
        border:1px solid #62bbe8;
    }
    td {
        width: 50px;
    }

    </style>
    </head><body>

    <div id='grid-tabs'>
        <ul>
        </ul>

            <div class='container'>
                <div class='scroll-area'>
                <table class='content'>
                    <tbody>
                        <tr><td>1.1</td><td>1.2</td><td>1.3</td></tr>
                        <tr><td>2.1</td><td>2.2</td><td>2.3</td></tr>
                        <tr><td>3.1</td><td>3.2</td><td>3.3</td></tr>
                        <tr><td>4.1</td><td>4.2</td><td>4.3</td></tr>
                        <tr><td>5.1</td><td>5.2</td><td>5.3</td></tr>
                        <tr><td>6.1</td><td>6.2</td><td>6.3</td></tr>
                        <tr><td>7.1</td><td>7.2</td><td>7.3</td></tr>
                        <tr><td>8.1</td><td>8.2</td><td>8.3</td></tr>
                        <tr><td>9.1</td><td>9.2</td><td>9.3</td></tr>
                        <tr><td>A.1</td><td>A.2</td><td>A.3</td></tr>
                        <tr><td>B.1</td><td>B.2</td><td>B.3</td></tr>
                        <tr><td>C.1</td><td>C.2</td><td>C.3</td></tr>
                    </tbody>
                </table>
                </div>
            </div>

    </div>

    <script type="text/javascript">
        jQuery('#grid-tabs').tabs({collapsible:true}).draggable({handle:'ul'}).resizable({alsoResize:'.container'});
        jQuery('#grid-tabs').tabs('add','#grid-tabs-1',"Tab 1");

    </script>
    </body>
A: 

Maybe you can help me with my draggable dilemma (seeing as how you seem to have a pretty good grasp of the concept). I too am having trouble with .draggable() disabling the scrollbar of a child element but I want the entire parent div to be draggable no matter where you click no it (other than the scrollbar). So I don't think I can use your {handle: 'ul'} method. Here is my code:

html:

<div id="resourceAsk">
            <div id="resource-body">
                <div id="res-text">
                    <div id="addition-res-container">
                        <div id="res-container"></div>
                    </div>
                </div>
            </div>
</div>

CSS:

#resource-body #res-text{
color:#fff;
font-size:12px;
padding:0 0 5px 0;
margin:10px 0 0 20px;
width:90%;
height:85%;
}

#res-text #addition-res-container{
display:none;
margin:15px 0 0 0;
height:75%;
width:100%;
overflow:auto;
}

jQuery:

$("div#resourceAsk").draggable({"scroll":false});

sadmicrowave