0

I have set a bootstrap table with the filter control extension. The table where I want to filter offers many popovers and tooltips. However, they stop working after filtering. What can I do to re-activate them?

An example of my code can be seen here (Location Type "Other" should have a popover, this works only before filtering for the first time):

<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>

... with the following javascript code:

$('#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/

Thanks for any help!

Ralf Jahr
  • 312
  • 2
  • 18

2 Answers2

0

You have to reinitialize popovers when changes are made in the table (like sorting, change of display and so on).

JS:

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

You can use Bootstrap's built-in functionality to reinitialize the popovers after table filtering in DOM:

$('#mainTable').on('post-body.bs.table', function () {
    $('.ajaxPopover').popover();
});
Ömer An
  • 600
  • 5
  • 16