我使用artTemplate写模板的时候 用bootstrap-table 给table加checkbox的时候无法显示
我把生成的html放在另一个页面又显示正常,然后我发现使用append()添加到
data-checkbox="true"没有解析 。这个要怎么解决
下面是生成的html代码:
$(function () { var htm = '<table class="table table-bordered table-condensed table-hover table-striped" data-toggle="table"> <thead><tr> <th data-field="state" data-checkbox="true"></th> <th data-field="Ids">Ids</th> <th data-field="Name">Name Title</th> <th data-field="Age">Age Title</th> <th>操作</th> </tr> </thead> <tbody> <tr id="col1"> <td data-field="state"></td> <td data-field="Ids">1</td> <td data-field="Name">Tom</td> <td data-field="Age">12</td> <td> <button type="button" class="btn btn-primary btn-xs" aria-label="Left Align"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加 </button> <button type="button" class="btn btn-primary btn-xs" aria-label="Left Align"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 修改 </button> <button type="button" class="btn btn-primary btn-xs" aria-label="Left Align"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 删除 </button> </td> </tr> <tr id="col2"> <td data-field="state"></td> <td data-field="Ids">2</td> <td data-field="Name">Jim</td> <td data-field="Age">13</td> <td> <button type="button" class="btn btn-primary btn-xs" aria-label="Left Align"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加 </button> <button type="button" class="btn btn-primary btn-xs" aria-label="Left Align"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 修改 </button> <button type="button" class="btn btn-primary btn-xs" aria-label="Left Align"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 删除 </button> </td> </tr> </tbody> </table>'; $("#table").append(htm); });
使用$(function())是在dom树加载完成后再执行,解决 直接页面进入时是加载 #table 下将内容插入解决