在过滤器控制不起作用的Bootstrap表中弹出(在过滤后)

时间:2016-06-16 14:01:48

标签: twitter-bootstrap-3 bootstrap-table bootstrap-popover

我已经设置了一个带过滤器控件扩展的引导表。我想要过滤的表提供了许多弹出窗口和工具提示。但是,他们在过滤后停止工作。我该怎么做才能重新激活它们?

我的代码示例可以在这里看到(位置类型"其他"应该有一个弹出窗口,这只在第一次过滤之前有效):

<table ref="mainTable" class="table table-striped table-bordered table-hover" 
       cellSpacing="0" id="mainTable" data-show-toggle="true" 
       data-show-columns="true" data-search="true" data-pagination="true" data-filter-control="true">
    <thead>
        <tr>
            <th data-field="state" data-checkbox="true"></th>
            <th data-field="CustomerName" data-sortable="true" data-filter-control="select">Customer Name</th>
            <th data-field="LocationType" data-sortable="true">Location Type</th>
            <th data-field="Location" data-sortable="true" data-filter-control="select">Location</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
            <td>Cap Corp</td>
            <td>Main</td>
            <td>Norwalk CT 06851</td>
        </tr>
        <tr>
            <td></td>
            <td>Cap Corp</td>
            <td><a class="ajaxPopover">Other</a></td>
            <td>Norwalk CT 06851</td>
        </tr>
        <tr>
            <td></td>
            <td>Tel</td>
            <td>Main</td>
            <td>Slough SL1 4DX</td>
        </tr>
        <tr>
            <td></td>
            <td>Tel</td>
            <td><a class="ajaxPopover">Other</a></td>
            <td>London W1B 5HQ</td>
        </tr>
    </tbody>
</table>

...使用以下javascript代码:

$('#mainTable').bootstrapTable({
});

// Add some popovers
$('.ajaxPopover').popover({
    html: true,
    placement: "auto right",
    container: 'body',
    content: "<b>Text</b> Other Text"
});

http://jsfiddle.net/7bpLrafx/4/

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

在表格中进行更改时(例如排序,更改显示等),您必须重新初始化弹出窗口。

JS:

$('#mainTable').on('all.bs.table', function () {
  $('.ajaxPopover').popover({
    html: true,
    placement: "auto right",
    container: 'body',
    content: "<b>Text</b> Other Text"
  });
});

答案 1 :(得分:0)

您可以使用Bootstrap的内置功能在DOM中进行表过滤后重新初始化弹出窗口:

$('#mainTable').on('post-body.bs.table', function () {
    $('.ajaxPopover').popover();
});
相关问题