Search code examples
javascriptjqueryjquery-pluginstablesorter

Does table sorter work without CSS?


I have a folder 'test' in the root of my hosting. I downloaded a sorter plugin from http://tablesorter.com and uploaded 'jquery' folder in the 'test' folder i created. Then I made an html table in the index.html file in the 'test' folder.

I entered the below within the head tag

<script type="text/javascript" src="jquery/jquery-latest.js"></script> 
<script type="text/javascript" src="jquery/jquery.tablesorter.js"></script>

Then I entered the following script within the head tag

<script>
    $(document).ready(function() 
        { 
            $("#myTable").tablesorter();
        } 
    ); 
</script>

In the table I entered

<table id="myTable" class="tablesorter" border="1" width="100%">

Still the sorter is not working... As far as I know, I followed proper instructions. What did i do something wrong?

MY path is public_html/mydomain.com/test The the files under test folder is

  1. jquery
  2. index.html

The files under jquery folder is

  1. jquery-latest.js
  2. jquery.metadata.js
  3. jquery.tablesorter.js
  4. jquery.tablesorter.min.js

After playing with the code for a while i found the problem. I downloaded a bootstrap template and added a table to it and at the bottom, just before /body tag there are 3 paths

<script src="./js/jquery-1.10.0.min.js"></script> 
<script src="./js/bootstrap/js/bootstrap.min.js"></script> 
<script src="./js/script.js"></script> 

If I remove this, the sorter works but then the website stops working. Any ideas???


Solution

  • I did a lot of juggling with the paths and I did not understand the logic but it worked.

    This is what I did

    I kept the following in head tag

    <script type="text/javascript" src="jquery/jquery-latest.js"></script> 
    <script type="text/javascript" src="jquery/jquery.tablesorter.js"></script> 
    

    I kept one more instance of the following in before /body end tag

    <script type="text/javascript" src="./js/jquery-latest.js"></script> 
    <script type="text/javascript" src="./js/jquery.tablesorter.js"></script> 
    

    and placed both the files in both the folders /jquery and the default /js folder included in the website template

    Phew!