1

当我将 bootstrap 3.0 popover 与placement: auto 一起使用时,它不起作用,并且它从表大小中流出。

放置:自动向右(意味着弹出框如果有位置则应向右流动,否则向左流动)

检查此链接:

http://jsfiddle.net/DTcHh/65

然而,当我把它放在桌子外面时,它应该是这样工作的!

$('button.hey').popover({
placement: 'auto left',
 html: true,
    //selector: '[rel="popover"]',
    content: function () {
        return "Hi man";
    }
})

任何的想法?

4

1 回答 1

3

在您的情况下,我建议您编写自己的回调来放置而不是使用“自动”。

如果您希望除最后一个 td 之外的所有按钮都“正确”。以下是放置的写法

$('button.hey').popover({
    placement: function(context,source){
        //check if current td is last one
        var td = $(source).closest('td');
        console.log(td);
        if(td.next().length == 0) {
            return 'left';
        }
        return 'right';
    },
     html: true,
     //selector: '[rel="popover"]',
     content: function () {
        return "Hi man";
     }
})

如果要根据位置进行处理,可以在放置回调中处理。

检查这个小提琴http://jsfiddle.net/codejack/DTcHh/66/

于 2013-10-27T06:53:57.993 回答