first declare functions then use
This commit is contained in:
parent
66bc536ebb
commit
286c93ef56
34
sortt.js
34
sortt.js
@ -8,21 +8,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Declare Functions
|
||||||
// test if jQuery is available
|
|
||||||
if(!window.jQuery) {
|
|
||||||
console.log("sortt.js: ERROR no jQuery found!");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
//use JQuery to bind event on each <th> with a "data-sortt" attribute
|
|
||||||
$('th').each(function() {
|
|
||||||
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
|
//create global function with main routine
|
||||||
window.sortt=function(normsort,revsort,isdefault){
|
window.sortt=function(normsort,revsort,isdefault){
|
||||||
@ -58,3 +44,21 @@ window.sortt=function(normsort,revsort,isdefault){
|
|||||||
//open url
|
//open url
|
||||||
window.location.replace(url.href);
|
window.location.replace(url.href);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//USE Functions
|
||||||
|
|
||||||
|
// test if jQuery is available
|
||||||
|
if(!window.jQuery) {
|
||||||
|
console.log("sortt.js: ERROR no jQuery found!");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//use JQuery to bind event on each <th> with a "data-sortt" attribute
|
||||||
|
$('th').each(function() {
|
||||||
|
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]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user