Rinku Kumar Rinku Kumar - 1 month ago 16
Jade Question

Why table header is also sorting with table data in jade?


Here is my code sample that is working perfect but the only problem is that when i click on table header its sort the data but also it include the table header itself.(Table header also sorted)


.Container.feedPageComponent.feedPageHome
script(src='/dashboard/bootstrap/js/tablesort.js')
script.
var something = function(text) {
console.log('something', text);
var value = text;
window.location.href="#{baseUrl}/feed/searchData/"+value
}
function init() {
new Tablesort(document.getElementById('myTable'));
}
window.onload = init;
div.input
input(type="text",id="demo" name="title", placeholder="Search Your Articles",onchange="something(this.value)")
div
table#myTable.table.table-striped
tr
th Date
th Time
th Title
th Type
th Delete
th User
th Share
- for item in data.rows.feedArray
tr
- var a = new Date(item.publishDate)
if a == "Invalid Date"
td N/A
td
else
td #{a.toDateString()}
td

Answer

The table header elements need to be in thead to be recognised as a table head. Then the rest goes into the tbody.

See also https://github.com/Mottie/tablesorter/issues/397 :

  ...
  table.table.tablesorter.table-bordered
    thead
      tr
        th Name
        th Label
        th Created
        th Expires
        th Type
        th Status
        th.last
    tbody
      each tape in tapes
  ...
Comments