2012-02-04 127 views
0

任何人都可以指向正确的方向。我一直在寻找,但无法找到我如何添加一个工具提示动态生成的数据。例如,我制作了一个显示电影标题的mysql结果列表,并且希望有一个工具提示,当鼠标悬停在鼠标上方时,可以提供导演,演员等额外信息。每次都会生成电影标题的随机列表。动态工具提示

我知道如何将工具提示添加到静态数据,但是如何在工具中添加工具提示?

任何指针或推动正确的方向将不胜感激。

+2

只要做你对静态数据做的事情......你通常为此做了什么? – 2012-02-04 22:24:49

回答

0

我在PHP中使用了Prototip 2,其中的提示是在生成页面时随时生成的。

基本上,我有这个代码为数据库中的一堆不同项目创建了一堆工具提示。此代码是整个页面的HTML的一部分。这恰好在zend框架视图脚本中,但是通用。

<?php foreach($this->items as $item): ?> 
<?php if ($item['statusText'] != ''): ?> 

tips.push(
     new Tip('led_<?php echo $item['boxsn']; ?>', '<?php echo $item['statusText']; ?>', { 
stem: 'leftMiddle', 
hook: { target: 'rightMiddle', tip: 'leftMiddle' }, 
style: 'protoblue', 
offset: { x: 5, y: 0 } 
}) 
); 
    <?php endif; ?> 
    <?php if ($item['alarms'] != ''): ?> 

    tips.push(
     new Tip('alarm_<?php echo $item['boxsn'] ?>', 
       '<?php echo $item['alarms'] ?>', { 
      stem: 'leftMiddle', 
      hook: { target: 'rightMiddle', tip: 'leftMiddle' }, 
      style: 'protoblue', 
      offset: { x: 5, y: 0 } 
     }) 
    ); 
    <?php endif; ?> 
<?php endforeach; ?> 

这给我留下了类似于对每个工具提示我创建了以下的输出:

tips.push(
    new Tip('led_091133000039', 'Item has not functioned since 02/03/12 01:30 PM', { 
     stem: 'leftMiddle', 
     hook: { target: 'rightMiddle', tip: 'leftMiddle' }, 
     style: 'protoblue', 
     offset: { x: 5, y: 0 } 
    }) 
); 

我甚至使用Ajax刷新该项目的状态和使用以下方法来从内存中清除所有的提示等等从阿贾克斯新的将被激活:

// prior to ajax update 
Tips.hideAll(); // prototip function to hide visible tooltips 

tips.each(function(t) { 
    delete t; 
}); 

delete tips; 
tips = []; 

// run ajax update 

led_091133000039每个ID是我想在上空盘旋,有提示显示图像的ID。该HTML在页面的前面生成。我有Javascript,它在HTML的底部创建所有提示。

希望能帮到你。