问题
I'm using Twitter Bootstrap 2.3.2 and I'm registering a popover to open whenever a td with a selector is hovered over. However I have noticed within the console that the content callback is being trigger twice. Is there a way to prevent this from happening?
$('#table-data').popover({
selector: '.td-popover',
trigger : 'hover',
content : function () {
console.log(this, arguments)
return 'hello';
}
});
<table id="table-data">
<tbody>
<tr>
<td></td>
<td class="td-popover"></td>
<td></td>
<td class="td-popover"></td>
</tr>
</tbody>
</table>
回答1:
your code is correct, this issue comes from bootstrap itself, they say that it is an intentional behavior and not a bug. see this github issue for more details https://github.com/twbs/bootstrap/issues/12563
FYI they didn't change this behavior in Bootstrap 3.2 (which is the current stable release), but I think that they plan to do it in the next one (3.2.1)
来源:https://stackoverflow.com/questions/24450533/bootstrap-delegated-pop-over-content-callback-triggered-twice