diff --git a/sortt.js b/sortt.js index 2510120..2dda20c 100644 --- a/sortt.js +++ b/sortt.js @@ -8,6 +8,22 @@ */ +///////////////////////////////////////////////// +// Be sure you already have loaded jQuery !!! // +///////////////////////////////////////////////// + + +//use JQuery to bind event on each with a "data-sortt" attribute +$('th').each(function() { + //console.log($(this)); + if ($(this)[0].dataset.sortt) $(this).on('click', function(e) { + var data = $(this)[0].dataset.sortt + data = data.split(","); + sortt(data[0],data[1],data[2]); + }); +}); + + //create global function with main routine window.sortt=function(normsort,revsort,isdefault){ //sortTable [normsort] (revsort) (isdefault)