2013-04-09 56 views
5

我在數據表上使用了bootstrap popover,因爲您將從每個單元格下方的jsFiddle中看到,單擊時會創建彈出式窗口。更改特定元素的引導程序彈出式位置

我想調整連續最後一個td的彈出位置或'放置位置',這個想法是當最後一個單元格被點擊時,彈出框將位於左側而不是頂部。

你會看到如果你滾動到表的最後點擊最後一個單元我已經實現了選擇,但沒有定位。

有關如何實現此目的的任何想法?

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

繼承人由JavaScript的popovers:

$(".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)) 
      } 
    }); 

回答

5

你可以一個功能分配給這樣的 '佈局' 選項..

$(".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' 

}) 
+0

謝謝你,完美的作品。 – Tom 2013-04-09 13:18:23