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);
}
);
I have a table:
<table style='display: none;'></table>
with content:
<tr class='dummyRow' style='display: none;'><td></td></tr>
To slideDown the row:
Note: the row and it's content (here it is
"table"
) both should be hidden before animation starts.To slideUp the row:
The second parameter (
function()
) is a callback.Simple!!
Note that there are also several options that can be added as parameters of the slide up/down functions (the most common being durations of
'slow'
and'fast'
).I did use the ideas provided here and faced some problems. I fixed them all and have a smooth one-liner I'd like to share.
It uses css on the td element. It reduces the height to 0px. That way only the height of the content of the newly created div-wrapper inside of each td element matters.
The slideUp is on slow. If you make it even slower you might realize some glitch. A small jump at the beginning. This is because of the mentioned css setting. But without those settings the row would not decrease in height. Only its content would.
At the end the tr element gets removed.
The whole line only contains JQuery and no native Javascript.
Hope it helps.
Here is an example code:
I'd like to add a comment to #Vinny's post but dont have the rep so have to post an answer...
Found a bug with your plugin - when you just pass an object in with arguments they get overwritten if no other arguments are passed in. Easily resolved by changing the order the arguments are processed, code below. I've also added an option for destroying the row after closing (only as I had a need for it!): $('#row_id').slideRow('up', true); // destroys the row