2012-12-04 86 views
3

我想爲qtip的多個實例設置一堆默認屬性,但它不工作。有可能或者我做錯了什麼?擴展qtip或其他選擇器插件的屬性

通用屬性

var qtipDefaults = { 
     show: 'mouseover', 
     hide: 'mouseout', 
     position: { 
      corner: { 
       target: 'bottomLeft', 
       tooltip: 'topLeft' 
      } 
     }, 
     style: { 
      name: 'dark' 
     } 
    }; 

實例化#1

$('#sbt_name').qtip({ 
     content: 'This is the Name of the Course' 
    }).extend(qtipDefaults); 

實例化#2

var sbt_name = $('#sbt_name').qtip({ 
     content: 'This is the Name of the Course' 
    }); 
    $.extend(sbt_name, qtipDefaults); 

回答

2

您必須在調用qtip插件之前準備qtip參數。試試這個:

$('#sbt_name').qtip($.extend(true, {}, qtipDefaults, { 
    content: 'This is the Name of the Course' 
})); 

$.extend()合併兩個或多個對象。 true參數表示它將進行深層複製。第一個對象是空的,用於保持原始qtipDefault不變。

+1

不錯,就像一個魅力工作,謝謝nrodic。 – SamJackSon

+0

在我的情況下,這有伎倆。我只想傳遞位於'position'數組中的'my'和'at'屬性。感謝您的解釋。 –

相關問題