tablesorter jquery plugin?
tablesorter jquery plugin?
Has anyone successfully integrated the jquery tablesorter plugin to the NWE engine? IT would be a nice addition to the search players screen if I could sort by the different values.
http://tablesorter.com/docs/
http://tablesorter.com/docs/
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: tablesorter jquery plugin?
Hmm, would make for a nice little plugin
Re: tablesorter jquery plugin?
So far all of my attempts have simply resulted in the following displaying in the Chrome console:
If I don't include a link to a jquery library with the link to the tablesorter library it complains it doesn't know what $ means. If I do include it (listed first of course) it resultsin the above error. I've tried calling it from the main.php file in the template folder as well as the index.php file in the root and tried adding lines in the common.php file.
I'm stumped...
Code: Select all
Uncaught TypeError: $(...).tablesorter is not a function
I'm stumped...
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: tablesorter jquery plugin?
Jquery must be included first which JQ is already included in the engine some variables that you should take advantage of is $content. There are a couple array keys here that you should be able to use:
$content['footer'] and $content['footerScript']
$content['footer'] and $content['footerScript']
Re: tablesorter jquery plugin?
Shouldn't just including a link to the Jquery library in the head of the main.php accomplish the same thing?
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: tablesorter jquery plugin?
In theory, yes. In reality meh! The engine is quite dynamic meaning everything is interchangeable through the module. Jquery shouldn't be loaded into the head of the main.php file if I recall correctly unless it is a custom template and done incorrectly. I believe it's loaded through the Ajax::IncludeLib() method which hot links to the Google hosted cdn library. Having 2 jquery libraries tends to break jquery as well.
So what you should do is:
I could have the array keys backwards and you may require the <script>tags for both array injections.
Also check your index.php file for correct implementations
So what you should do is:
Code: Select all
global $content;
$content['footer'] .= "path/to/tablesorter.js";
$content['footerScript'] .= "$('#table').tablesorter();";//this is your table sorter jquery call
Also check your index.php file for correct implementations
Re: tablesorter jquery plugin?
...and would those lines go in the head of the main.php in the template? There was already a call to $content['header'] in there.
Like this?
Like this?
Code: Select all
<?php echo $content['header'];
echo $content['footer'] .= "path/to/tablesorter.js";
echo $content['footerScript'] .= "$('#myTable').tablesorter();";//this is your table sorter jquery call
?>
Re: tablesorter jquery plugin?
So where should this go?
Code: Select all
$content['footerScript'] .= "<script src='{$webBaseDir}js/jquery.tablesorter.js'></script>";
$content['footerScript'] .= "<script>\$('#myTable').tablesorter();</script>";
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: tablesorter jquery plugin?
That would go in your content.php filecbsarge wrote:So where should this go?
Code: Select all
$content['footerScript'] .= "<script src='{$webBaseDir}js/jquery.tablesorter.js'></script>"; $content['footerScript'] .= "<script>\$('#myTable').tablesorter();</script>";
Re: tablesorter jquery plugin?
ugh...
Thanks Kyle but, apparently I still need some hand-holding. Let me know if you decide to take a look at this and if you figure it out. I'm admitting defeat for now.
Thanks Kyle but, apparently I still need some hand-holding. Let me know if you decide to take a look at this and if you figure it out. I'm admitting defeat for now.