这是我的代码示例,可以完美运行,但是唯一的问题是,当我单击表头时,它对数据进行排序,但也包括表头本身(表头也已排序)


.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

最佳答案

表头元素必须在thead中才能被识别为表头。然后其余的进入tbody

另请参见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
  ...

关于javascript - 为什么表头也用 Jade 中的表数据排序?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39675720/

10-12 00:56