I have a table, which I want to split into rows of x, which should be removed from the table and added to subpages I'm creating. I can slice the table, but detach()
doesn't work and I'm not sure what I'm doing wrong.
Here is what I have:
var rows = $( table ).find( "tbody tr, TBODY TR" ).toArray(),
splitRows = [];
for( i = 0; i < rows.length; i += rowsPerPageS ){
// table rows for each subpage
var takeAway = splitRows.push( rows.slice(i, i + rowsPerPageS ) );
// split the tabel and create subpages
newPage = takeAway.detach()
.wrap(...
}
Question:
Console tells me takeAway.detach is not a function and I don't know what I'm doing wrong. How do I remove my sliced table-rows and wrap them correctly?
Just found the solution. This works:
var rows = $( table ).find( "tbody tr, TBODY TR" )
splitRows = [];
for( i = 0; i < rows.length; i += rowsPerPageS ){
// split table into array
splitRows.push( rows.slice(i, i + rowsPerPageS ) );
// table rows for each subpage
var takeAway = splitRows[i],
newPage;
// split the table and create subpages
newPage = takeAway.detach()
.wrap...
So I guess I need to split into the array first and then takeaway the respective array elements.
Thanks for helping!