2011-11-25 27 views
0

摘录我listSuccess.php的:当鼠标悬停在消息上时,如何查看实际消息?

foreach ($pager->getResults() as $msg) 
{ 
    //listing the messages' subjects here 
    <a href="<?php echo url_for('messagebox/read?cursor=').$cursor ?>" style='color:#ff0000 !important' onmouseover="document.getElementById('hiddenDiv').style.display = 'none'" class='spn_small_red_rbc'><?php echo $msg->getSubject();?></a> 
    <div id="hiddenDiv" style="display: none">Show the actual message here</div> 
} 

以上不工作,虽然 任何帮助吗? 谢谢

+1

,如果你给它会帮助描述你想要做什么的更多细节。我不确定什么“当鼠标悬停在消息上时看到实际的消息”意味着 - 哪条消息?这是一个图像或文字?全部数据来自哪里?会生成服务器端还是客户端?你想在什么地方/如何渲染“实际消息” - 在弹出窗口中使用浮动div替换文档另一部分中的文本?等 –

+0

...并遵循编辑,它是如何“不工作”?这种解释不允许人们解决问题。你期望的输出是什么?以及你实际得到了什么? –

+0

yikes抱歉..请参阅编辑信息是文本...浮动div我猜?谢谢 –

回答

0

我使用jQuery的工具提示,它是有据可查的,工作简单,是功能丰富。

您可以阅读实况,并在这里学习演示:http://flowplayer.org/tools/tooltip/index.html

旁边,@Baszz解决方案将工作太,我会建议使用JavaScript助手的功能symfony的解决方案

<?php javascript_tag(); ?> 

    // please study http://api.jquery.com/ready/ 
    jQuery().ready(function(){ 
     // Example for jQuery TOOLS tooltip 
     jQuery(".spn_small_red_rbc").tooltip(); 
    }); 

<?php end_javascript_tag(); ?> 
+0

谢谢,我会读到这一点 –

0

清理你的代码,并提取样式和脚本。这使得它更具有可读性(使用jQuery):

<style> 
    a.spn_small_red_rbc { color: #ff0000; } 
    div .hiddenDiv { display: none; } 
</style> 

<script> 
    $('a.spn_small_red_rbc').hover(function(){ 
     // Mouse enter 
     $(this).next('div').show(); 
    }, 
    function(){ 
     // Mouse leave 
     $(this).next('div').hide(); 
    }); 
</script> 

<? foreach ($pager->getResults() as $msg) { ?> 
    <a href="<?=url_for('messagebox/read?cursor=').$cursor?>" class="spn_small_red_rbc"><?=$msg->getSubject()?></a> 
    <div id="hiddenDiv">Show the actual message here</div> 
<? } ?> 
相关问题