问题
I have popup with autosized attribute. Panel contains fields for search, search button, datatable and datascroller. After press search button or select page in datascroller javascript is called. Javascript is used for move popup to center of browser visible area. All work fine, except popup shadow is stay for previous panel position when popup is already moved.
Button code:
<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));
};
I have tried different version of javascript, but with same side effect:
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));
};
Screen shots:
Thanks for any help or comments.
回答1:
Problem was fixed with adding hide and show in end of javascript:
modalPanel.hide(); modalPanel.show();
回答2:
I resolved the problem on calling resize () action of the popup.
In your case, it should be modalPanel.resize()
.
来源:https://stackoverflow.com/questions/19570194/incorrect-popup-shadow-position-after-moving-popup-in-richfaces-4-x