【问题标题】:How to set the popUp Panel show at the position of mouse cursor in richFaces如何在richFaces中的鼠标光标位置设置弹出面板显示
【发布时间】:2012-08-25 20:48:03
【问题描述】:

是否有任何属性可以将弹出面板显示在richFaces 4中的鼠标光标位置?

我现在想到的一种解决方法是在丰富的show event中产生影响:component()。 Show() 函数,通过javascript设置弹出窗口的位置。

【问题讨论】:

    标签: jsf-2 richfaces


    【解决方案1】:

    您可以通过javascript直接处理richfaces模态面板的显示,如图Here

    this js function below 将为您提供鼠标指针的 x/y 坐标位置,您可以将其返回值作为参数传递给Richfaces.showModalPanel 函数

    function getPosition(e) { e = e || window.event; var cursor = {x:0, y:0}; if (e.pageX || e.pageY) { cursor.x = e.pageX; cursor.y = e.pageY; } else { var de = document.documentElement; var b = document.body; cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0); cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0); } return cursor; }

    这样你就可以拥有RichFaces.showModalPanel('panel',{top:getPosition(ev).y,left:getPosition(ev).x})

    对可怕的 javascript 感到抱歉。

    【讨论】:

    • 非常感谢您的回答。但不幸的是,我尝试过但没有成功:|这是我的 XHTML 文件:
    • 这里没有文件。它究竟是如何/在哪里失败的?损坏的 javascript(您可以从浏览器开发人员控制台中得知)或弹出窗口仍然显示在鼠标指针位置之外
    • 对不起,我太忙了,以至于忘记回答你的问题。当您使用commandLink、commandButton 和Action Method 时会出现问题(当您要在该方法之后渲染面板时),页面将显示2 弹出窗口。最后我已经解决了这个问题,我很快就会在我的 wordpress 中进行演示:)。谢谢你的帮助:) phandanghung.wordpress.com
    猜你喜欢
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-04
    相关资源
    最近更新 更多