diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ae031c --- /dev/null +++ b/README.md @@ -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. diff --git a/responsive-tables.js b/responsive-tables.js index 1a862f1..d777a90 100644 --- a/responsive-tables.js +++ b/responsive-tables.js @@ -1,4 +1,4 @@ -$(document).ready(function() { +$(function() { var switched = false; var updateTables = function() { if (($(window).width() < 767) && !switched ){ @@ -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("
"); - - 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("
"); - original.wrap("
"); + $(window).on("resize", updateTables); + + function splitTable(original) { + original.wrap("
"); + + 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("
"); + original.wrap("
"); 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'), @@ -63,5 +61,4 @@ $(document).ready(function() { $(this).height(heights[index]); }); } - -}); +}); \ No newline at end of file