2017-08-29 116 views
0

我正在使用Material Design lite和可选数据表。我试图在从firebase获取信息后使用javascript放置表格行。动态材质设计精简版可选数据表

我想要使用文档(https://getmdl.io/components/index.html#tables-section)中显示的可选择的行,但是当我使用javascript放置行时,我没有得到表格正文中的复选框。

我的HTML

<div class="mdl-card mdl-shadow--2dp full-width login-activity-card"> 
    <table class="mdl-data-table mdl-js-data-table mdl-data-table--selectable full-width"> 
     <thead> 
      <tr> 
       <th class="mdl-data-table__cell--non-numeric">Login Time</th> 
       <th class="mdl-data-table__cell--non-numeric">Login Date</th> 
      </tr> 
     </thead> 
     <tbody></tbody> 
    </table> 
</div> 

我的JavaScript

$(".login-activity-card .mdl-data-table tbody").html(
    '<tr>'+ 
     '<td class="mdl-data-table__cell--non-numeric">1:53 PM</td>'+ 
     '<td class="mdl-data-table__cell--non-numeric">Aug 05, 2017</td>'+ 
    '</tr>' 
) 

我得到的头,但没有对行的复选框。

enter image description here

我已经看到了GitHub的仓库,这是在2015年弃用,但它今天仍然在文档中?它给了使用Wiki的方向,但我没有找到任何内容。

这是完全不可能的还是我错过了什么?

+0

我不能重现该问题的wiki条目。使用您的代码检查[codepen](https://codepen.io/krvajal/pen/LjvamX) –

回答

0

该库仅用于静态内容。如果您添加动态内容,则必须确保致电componentHandler.upgradeAllRegistered()

有关详情,请有关componentHandler

相关问题