Skip to content

Commit

Permalink
Correctly invoke stupidtable_buildtable
Browse files Browse the repository at this point in the history
  • Loading branch information
joequery committed Jul 2, 2017
1 parent 47bed51 commit 9d197b9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions stupidtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sortFns = sortFns || {};
sortFns = $.extend({}, $.fn.stupidtable.default_sort_fns, sortFns);
$table.data('sortFns', sortFns);
$.fn.stupidtable_buildtable($table);
$table.stupidtable_buildtable();

$table.on("click.stupidtable", "thead th", function() {
$(this).stupidsort();
Expand Down Expand Up @@ -84,10 +84,10 @@
// `beforetablesort` callback. Also avoids locking up the browser too much.
setTimeout(function() {
if(!$table.stupidtable.settings.will_manually_build_table){
$.fn.stupidtable_buildtable($table);
$table.stupidtable_buildtable();
}
var table_structure = $table.data('stupidsort_internaltable');
// Sort by the data-order-by value. Sort by position in the table if
// Sort by the data-sort value. Sort by position in the table if
// values are the same. This enforces a stable sort across all browsers.
// See https://bugs.chromium.org/p/v8/issues/detail?id=90
table_structure.sort(function(e1, e2){
Expand Down Expand Up @@ -179,7 +179,9 @@
}
};

$.fn.stupidtable_buildtable = function($table){
$.fn.stupidtable_buildtable = function(){
return this.each(function() {
var $table = $(this);
var table_structure = [];
var trs = $table.children("tbody").children("tr");
trs.each(function(index,tr) {
Expand Down Expand Up @@ -207,9 +209,8 @@
});
table_structure.push(ele);
});

$table.data('stupidsort_internaltable', table_structure);
return table_structure;
});
};

})(jQuery);

0 comments on commit 9d197b9

Please sign in to comment.