I'm trying to add a row to a table and have that row slide into view, however the slidedown function seems to be adding a display:block style to the table row which messes up the layout.
Any ideas how to work around this?
Here's the code:
$.get('/some_url',
{ 'val1': id },
function (data) {
var row = $('#detailed_edit_row');
row.hide();
row.html(data);
row.slideDown(1000);
}
);
Animations are not supported on table rows.
From "Learning jQuery" by Chaffer and Swedberg
You can wrap your td contents in a div and use the slideDown on that. You need to decide if the animation is worth the extra markup.
You could try wrapping the contents of the row in a
<span>
and having your selector be$('#detailed_edit_row span');
- a bit hackish, but I just tested it and it works. I also tried thetable-row
suggestion above and it didn't seem to work.update: I've been playing around with this problem, and from all indications jQuery needs the object it performs slideDown on to be a block element. So, no dice. I was able to conjure up a table where I used slideDown on a cell and it didn't affect the layout at all, so I am not sure how yours is set up. I think your only solution is to refactor the table in such a way that it's ok with that cell being a block, or just
.show();
the damn thing. Good luck.I've gotten around this by using the td elements in the row:
Animating the row itself causes strange behaviour, mostly async animation problems.
For the above code, I am highlighting a row that gets dragged and dropped around in the table to highlight that the update has succeeded. Hope this helps someone.
Select the contents of the row like this:
.contents() - Get the children of each element in the set of matched elements, including text and comment nodes.
I want to slide whole tbody and I've managed this problem by combining fade and slide effects.
I've done this in 3 stages (2nd and 3rd steps are replaced in case you want to slide down or up)
Example of slideUp:
Here's a plug-in that I wrote up for this, it takes a little from Fletch's implementation, but mine is used solely to slide a row up or down (no inserting rows).
Basic Usage:
Pass slide options as individual arguments:
Basically, for the slide down animation, the plug-in wraps the contents of the cells in DIVs, animates those, then removes them, and vice versa for the slide up (with some extra steps to get rid of the cell padding). It also returns the object you called it on, so you can chain methods like so:
Hope this helps someone.