Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# responsive-tables
Tables that work responsively on small devices.
This fork was created in order to fix the incompatibility of this project with jQuery 3.x.
41 changes: 19 additions & 22 deletions responsive-tables.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).ready(function() {
$(function() {
var switched = false;
var updateTables = function() {
if (($(window).width() < 767) && !switched ){
Expand All @@ -16,31 +16,29 @@ $(document).ready(function() {
}
};

$(window).load(updateTables);
$(window).on('load', updateTables);
$(window).on("redraw",function(){switched=false;updateTables();}); // An event to listen for
$(window).on("resize", updateTables);


function splitTable(original)
{
original.wrap("<div class='table-wrapper' />");

var copy = original.clone();
copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
copy.removeClass("responsive");

original.closest(".table-wrapper").append(copy);
copy.wrap("<div class='pinned' />");
original.wrap("<div class='scrollable' />");
$(window).on("resize", updateTables);

function splitTable(original) {
original.wrap("<div class='table-wrapper' />");

var copy = original.clone();
copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
copy.removeClass("responsive");

original.closest(".table-wrapper").append(copy);
copy.wrap("<div class='pinned' />");
original.wrap("<div class='scrollable' />");

setCellHeights(original, copy);
}
function unsplitTable(original) {
}
function unsplitTable(original) {
original.closest(".table-wrapper").find(".pinned").remove();
original.unwrap();
original.unwrap();
}
}

function setCellHeights(original, copy) {
var tr = original.find('tr'),
Expand All @@ -63,5 +61,4 @@ $(document).ready(function() {
$(this).height(heights[index]);
});
}

});
});