为什么表头也用jade中的表数据排序?

时间:2016-09-24 11:17:40

标签: javascript html pug

  

这是我的代码示例工作正常,但唯一的问题是,当我点击表头时,它对数据进行排序,但它也包括表头本身。(表头也排序)

.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

1 个答案:

答案 0 :(得分:0)

表头元素需要在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
  ...