2010-12-15 116 views
2

我正在用jQuery AJAX調用加載我的頁面的一部分,並希望在該部分中使用qTips。通常在通過AJAX加載jQuery函數時,您可以使用.live()函數。有沒有辦法使用.live()附加qTip或是否有qTip等效?qtip live()支持

我聽說qTip 2.0會有這種支持,但我不相信2.0已經準備好了。

有沒有人有解決方法?

下面是完整的代碼,我認爲應該工作,但似乎並不:

$('.editquestion').live('click', function() { 
       $(this).qtip({ 
        overwrite:false, 
        content: { 
         url: $(this).attr('href'), 
         data: { id: 5 }, 
         method: 'get', 
         title: { 
          text: 'Edit Question', 
          button: 'Close' 
         }, 
         cache: false, 
        }, 
        position: { 
         target: $(document.body), // Position it via the document body... 
         corner: 'center' // ...at the center of the viewport 
        }, 
        show: { 
         ready:true, 
        }, 
        hide: false, 
        style: { 
         width: { 
          max: 550, 
          min: 550 
         }, 
         height: { 
          max: 300, 
          min:300 
         }, 
         padding: '14px', 
         border: { 
          width: 9, 
          radius: 9, 
          color: '#666666' 
         }, 
         name: 'light' 
        }, 
        api: { 
         beforeShow: function() { 
          // Fade in the modal "blanket" using the defined show speed 
          $('#qtip-blanket').fadeIn(this.options.show.effect.length); 
         }, 
         beforeHide: function() { 
          // Fade out the modal "blanket" using the defined hide speed 
          $('#qtip-blanket').fadeOut(this.options.hide.effect.length); 
         } 
        } 
       }); 
       return false; 
      }); 

編輯:也許我還應該提到的是,qtip使用Ajax加載表單。

回答

2
+0

嗯,謝謝你的迴應。第一個鏈接是我見過的。這對我來說合理,邏輯上應該工作,但似乎沒有。它的行爲就像創建自己的副本一樣。每次我打電話給qTip時,都會打更多的電話(例如,第一次,第二次:2等)。第二個環節對我來說沒有多大意義。這不是你在靜態頁面上添加qtips的正常方式嗎? – emachine 2010-12-15 16:53:54

0

您應該在加載頁面的新的部分時,而不是在點擊附加qtip。

您也可以嘗試檢查qtip是否已附加到單擊的對象,然後再單擊附加。 Firebug會告訴你要檢查什麼。