2015-08-19 22 views
0

該鏈接包含RichFaces的示例4 popuppanel的popuppanel: richfaces popuppanel example如何使RichFaces的彈出向上

這裏是代碼:

<rich:toolbar height="26px" id="tb"> 
    <rich:toolbarGroup location="right"> 
     <h:outputLink value="#"> 
      <rich:componentControl event="click" operation="show" target="ls"> 
       <a4j:param name="event" value="event" noEscape="true" /> 
       <rich:hashParam> 
        <a4j:param noEscape="true" name="top" 
           value="jQuery(#{rich:element('tb')}).offset().top + jQuery(#{rich:element('tb')}).height()" /> 
        <a4j:param noEscape="true" name="left" 
           value="jQuery(#{rich:element('tb')}).offset().left + jQuery(#{rich:element('tb')}).width() - p_width" /> 
       </rich:hashParam> 
      </rich:componentControl> 
      Search 
     </h:outputLink> 
    </rich:toolbarGroup> 
</rich:toolbar> 
<rich:popupPanel header="Enter Search Terms" id="ls" autosized="true" modal="false" moveable="false" resizeable="false" followByScroll="false" > 
    <h:panelGrid columns="3"> 
     <h:outputText value="Search:" /> 
     <h:inputText /> 
     <h:outputLink onclick="#{rich:component('ls')}.hide(event); return false;" value="#">Search 
     </h:outputLink> 
    </h:panelGrid> 
</rich:popupPanel> 
<h:outputScript type="text/javascript" target="body"> 
    p_width = #{rich:component('ls')}.width(); 
</h:outputScript> 

但彈出窗口出現在隨機的地方,即有時在酒吧下面,然後滾動,有時在上面。是否有可能確保它始終顯示在酒吧上方並附着在酒吧上方?

回答

1

topleft參數設置面板的位置,將其更改爲您希望將面板,或者直接撥打電話的方法:

RichFaces.component('panelId').show(null, {top: "800px", left: "500px"}) 

您使用的示例的一部分專門設置面板下方的面板,所以當面板出現在面板上時應該不會感到意外。