Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix cell heights for mobile rows.

  • Loading branch information...
commit a61cf0b7e16b8b0f3555178dafb1f894c6f39fba 1 parent 349ecea
@mrsweaters mrsweaters authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 responsive-tables.js
View
24 responsive-tables.js
@@ -31,6 +31,8 @@ $(document).ready(function() {
original.closest(".table-wrapper").append(copy);
copy.wrap("<div class='pinned' />");
original.wrap("<div class='scrollable' />");
+
+ setCellHeights(original, copy);
}
function unsplitTable(original) {
@@ -39,4 +41,26 @@ $(document).ready(function() {
original.unwrap();
}
+ function setCellHeights(original, copy) {
+ var tr = original.find('tr'),
+ tr_copy = copy.find('tr'),
+ heights = [];
+
+ tr.each(function (index) {
+ var self = $(this),
+ tx = self.find('th, td');
+
+ tx.each(function () {
+ var height = $(this).outerHeight(true);
+ heights[index] = heights[index] || 0;
+ if (height > heights[index]) heights[index] = height;
+ });
+
+ });
+
+ tr_copy.each(function (index) {
+ $(this).height(heights[index]);
+ });
+ }
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.