【问题标题】:Changing the bootstrap popover position for a particular element更改特定元素的引导弹出位置
【发布时间】:2013-04-09 21:13:01
【问题描述】:

我在数据表上使用bootstrap popover,正如您从下面的 jsFiddle 中看到的那样,单击每个单元格时都会创建一个弹出框。

我正在尝试为连续的最后一个 td 调整弹出框的位置或“放置”,其想法是单击最后一个单元格时,弹出框将位于左侧而不是顶部。

如果您滚动到表格末尾,您将看到单击我已实现选择但未实现定位的最后一个单元格。

关于如何实现这一点的任何想法?

http://jsfiddle.net/N8NNC/1/

这里是 javascript 的弹出框:

$(".metapop").popover({ 

    html: true,
    trigger: 'manual',
    placement: 'top',
    title: "You clicked on this cell:",
    content: 'hello this is a popover'

}).click(function(e) {

        $('.popover').hide();
        $(this).popover('show');
        if($(this).parent().is('td:last-child'))
            {
                alert($(this))
            }
    });

【问题讨论】:

    标签: javascript jquery twitter-bootstrap popup


    【解决方案1】:

    您可以像这样为“放置”选项分配一个功能..

    $(".metapop").popover({ 
    
        html: true,
        trigger: 'manual',
        placement: function(pop,ele){
            if($(ele).parent().is('td:last-child')){
            return 'left'
            }else{
            return 'top'
            }
        },
        title: "You clicked on this cell:",
        content: 'hello this is a popover'
    
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-24
      • 1970-01-01
      • 2019-04-20
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多