如何使用在运行时分配给页面元素的qTip2创建工具提示

时间:2011-01-26 01:10:02

标签: jquery jquery-plugins qtip2

我正在尝试创建qTip2气泡但在加载时不显示。然后在点击的任何图像下显示它。

请告知最佳方法是什么。 (使用qTip解决屏幕外的气泡)。

由于

编辑:

查看http://jsfiddle.net/jnbPP/5/的问题(寻找正确的方法)

1 个答案:

答案 0 :(得分:1)

那么你需要在点击时加载它,例如:

$('img[title]').live('click', function(event) {
        $(this).qtip({
              overwrite: false,
              content: {           
                 text: $(this).attr('title') ,
              },
              position: {
                  my: 'top center', 
                  at: 'bottom center', 
                  adjust : {
                    screen : true
                  }
              },  
              show: {
                 event: event.type,
                 ready: true,
                 solo: true
              },
              hide: 'unfocus',
                style: {
                    classes: 'ui-tooltip-light'
              }
           });
    });

查看我的小提琴:EXAMPLE

使用

adjust : {
     screen : true
}

将工具提示保留在屏幕上。

在这里CLICK

$('img[title]').live('click', function(event) {
    var content = $('#settings').clone();
    $('input', content).val( $(this).width() );

    $(this).qtip({
      overwrite: false,
      content: {           
            text: content,
            title: {
                text: ' ',
               button: true
            }
         },
         position: {
             my: 'top center',  // Position my top left...
             at: 'bottom center', // at the bottom right of...
             viewport: $(window)
          },

      show: {
         event: event.type,
         ready: true,
         solo: true
      },
      hide: 'unfocus',
         style: {
               classes: 'ui-tooltip-ajax ui-tooltip-light'
         }
   });
});