[英]Open rich:popupPanel on current mouse cursor position with jquery
The following code will open a rich:popupPanel vertically aligned with and directly below the h:commandButton: 以下代码将打开一个与h:commandButton垂直对齐并位于其正下方的rich:popupPanel:
<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" ....
Now I'd like the popup to appear where the cursor is at the moment when user clicks the <h:commandButton>
, but I couldn't find out how to do this (unfortunately I don't have any practice with jquery). 现在,我希望弹出窗口显示在用户单击<h:commandButton>
时光标所在的位置,但是我不知道如何执行此操作(不幸的是,我对jquery没有任何练习)。 Can you please help me? 你能帮我么?
Thanks 谢谢
maybe you should try this: 也许您应该尝试这样:
<a4j:param noEscape="true" name="top"
value="jQuery(#{rich:element('openBtn')}.parentNode).offset().top + jQuery(#{rich:element('openBtn')}.parentNode).height() - $(window).scrollTop()" />
This sets the value of "top" to the position of the element subtracting the vertical position of the scroll bar. 这会将“ top”的值设置为元素的位置减去滚动条的垂直位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.