1

我有自动调整属性的弹出窗口。面板包含用于搜索、搜索按钮、数据表和数据滚动条的字段。按下搜索按钮或在 datascroller 中选择页面后,将调用 javascript。Javascript 用于将弹出窗口移动到浏览器可见区域的中心。一切正常,除了弹出阴影在弹出窗口已经移动时保留在先前的面板位置。

按钮代码:

<a4j:commandButton id="searchButton"
    value="#{msg.search}"
    action="#{chAction.searchSegments}"
    styleClass="richButton"
    render="clientCategoryCandidateTable"
    oncomplete="centerPanel();" />

Javascript:

function centerPanel() {
    var modalPanel = #{rich:component('addToSegmentsPanel')};
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupWidth = modalPanel.width();
    var popupHeight = modalPanel.height();
    modalPanel.setLeft(Math.max(0, (windowWidth-popupWidth)/2));
    modalPanel.setTop(Math.max(0, (windowHeight-popupHeight)/2));
};

我尝试了不同版本的 javascript,但具有相同的副作用:

function centerPopup() {
    var popup = #{rich:component('addToSegmentsPanel')};
    popup.moveTo(Math.max(0, (window.innerWidth-popup.width())/2),
                 Math.max(0, (window.innerHeight-popup.height())/2));
};

屏幕截图: 调用javascript前弹出 调用javascript后弹出

感谢您的任何帮助或评论。

4

2 回答 2

1

通过在 javascript 末尾添加隐藏和显示解决了问题:

modalPanel.hide(); modalPanel.show();
于 2013-10-24T16:38:45.953 回答
0

我解决了调用弹出窗口的 resize () 操作的问题。在你的情况下,它应该是modalPanel.resize().

于 2014-03-11T09:55:10.747 回答