0

I have a table with some hidden rows and a clickable button that reveals those hidden rows. The problem is that, when I use the link, the rows get revealed but the body doesn't update its height. (But it does update when I open the chrome console and close it)

css:

table tr.hide-row {
   display:none;
}

jquery:

$(document).on('click', 'a.openallrows', function(e) {
    $('.hide-row').show();
    e.preventDefault();
});

html

<table>
    <tbody>
        <tr>
            <td colspan="4">visible</td>
        </tr>
        <tr class="hide-row">
            <td>This is hidden</td>
            <td>-</td>
            <td>--</td>
            <td>---</td>
        </tr>
    </tbody>
</table>

I have a lot of hidden rows. And when they all get shown, they overlap the page footer and that's not what I was going for..

Update!

<div class="grid" style="width: 272.5px; left: 0px; top: 10px; position: absolute;">
     table is inside here  
</div>

The table is inside a grid which has position absolute! The position is automatically added by BlocksIt.js

Kristjan Kirpu
  • 674
  • 1
  • 7
  • 26

4 Answers4

0

try this css code

table{
height:auto !important;
}
0

What happens if you change the containing div as such:

<div class="grid" style="width: 272.5px;margin-top:10px;">
     table is inside here  
</div>
Dimitri
  • 6,923
  • 4
  • 35
  • 49
  • BlocksIt.js will re-position the selected elements using CSS absolute position property. It has the capability to calculate the top and left positions for an element based on certain criteria, like below: Start the new block from left to right, and Place the new block under shortest block. – Kristjan Kirpu Feb 10 '14 at 18:11
  • @Kristjan Kirpu - I suggest you mention Blockslt.js somewhere in the question to prevent further confusion. As far as your question goes, unfortunately I'm not familiar with the above mentioned library, but most likely it fails to reevaluade div's height. Could be due to an error. Have you examined the console to see if any JS errors are thrown? – Dimitri Feb 10 '14 at 18:14
  • No JS errors are thrown. I found some other BlocksIt.js scripts that fix some errors. I'll try them out and I'll update my status asap. – Kristjan Kirpu Feb 10 '14 at 18:17
0

Ive got a cool idea.

You could easily just put a container around it with a height and width of 100% and then grab its height and the height of the parent element to boxes.

Everytime a new box is opened, compare it to the height of the container, and add to the container's height if the margin between the two becomes to small.

Ive made a fiddle. I used an increment code on the height. Imagine the red box is your "hide-row" class. In this situation(because Im pressed for time,) I have pretended to add on 40px(which will represent the height of a td.) Everytime it increases, the container increases IF the maximum margin would be exceeded in the following add. So I incremented the height of the container. I recommend your container contain the entire page.

$(".higher").click(function(){
    var allheight = $(".all").height() - 80;
    var red = $(".higher").height();
    $(".higher").css("height", "+=40px");
    if(red > allheight){
        $(".all").css("height", "+=40px");
    }
});

Click Here to see it.

You could place as many block columns in this section as needed.

0

The block was overlapping the footer because it didn't update its height value. Luckily I was able to find a different script that lays out the blocks. It has a function to call a refresh to itself so it doesn't overlap other elements.

If someone ever has a similar problem I suggest you try out https://github.com/GBKS/Wookmark-jQuery it has all the same functions as BlocksIt.js and even more.

This was the function that I found very necessary for my project that Wookmark has $('.grid').trigger('refreshWookmark'); it refreshes the block.

Kristjan Kirpu
  • 674
  • 1
  • 7
  • 26