2010-12-15 44 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会告诉你要检查什么。