2013-05-08 40 views
0

下面的代码将打开一个丰富:popupPanel垂直对准和直接的H如下:的commandButton:打开丰富:在当前鼠标光标位置popupPanel使用jQuery

<h:commandButton value="Open popup" id="openBtn"> 
    <rich:componentControl event="click" target="myPopup" 
     operation="show"> 
     <a4j:param name="event" value="event" noEscape="true" /> 
     <rich:hashParam> 
      <a4j:param noEscape="true" name="top" 
       value="jQuery(#{rich:element('openBtn')}.parentNode).offset().top + jQuery(#{rich:element('openBtn')}.parentNode).height()" /> 
      <a4j:param noEscape="true" name="left" 
       value="jQuery(#{rich:element('openBtn')}.parentNode).offset().left" /> 
     </rich:hashParam> 
    </rich:componentControl> 
</h:commandButton> 
<rich:popupPanel id="myPopup" modal="false" autosized="true" resizeable="false" .... 

现在,我想在弹出出现光标位于用户点击<h:commandButton>时,但我无法找到如何做到这一点(不幸的是,我没有任何jQuery的做法)。你能帮我么?

感谢

+0

我不明白你的意思'现在,我想,让鼠标光标成为popup'的左上角你能否解释一下? – Nikhil 2013-05-10 10:01:40

+0

当然:弹出窗口是一个矩形,我想让它的左上角接收当前鼠标位置的坐标。谢谢! – Federico 2013-05-10 10:55:03

+0

纠正我,如果我错了:你希望用户的鼠标光标指向在那个角落使用jQuery? – Nikhil 2013-05-10 11:05:22

回答

1

也许你应该试试这个:

<a4j:param noEscape="true" name="top" 
value="jQuery(#{rich:element('openBtn')}.parentNode).offset().top + jQuery(#{rich:element('openBtn')}.parentNode).height() - $(window).scrollTop()" /> 

这台“顶”与元素减去滚动条的垂直位置的位置值。

jQuery scrollTop()