1 Reply Latest reply on Mar 29, 2010 4:25 AM by ilya_shaikovsky

    When ModalPanel opens, scroll bar moves to the top

    apanag

      Hi,

       

      when opening the modal panel from the exadel example or any similar code the browser scroll bar moves to the top.

      (of course, in case that the browser scroll bars are already visible)

       

      The reason is that the tag that generates the "open" action is a hyperlink pointing to #.

       

      The RF example code:

       

      <h:outputLink value="#" id="link">
               Show Modal Panel
               <rich:componentControl for="panel" attachTo="link" operation="show" event="onclick"/>
      </h:outputLink>

       

      The generated HTML:

       

      <a href="#" name="j_id352:link" id="j_id352:link">
              Show Modal Panel

      <script type="text/javascript">Richfaces.componentControl.attachAvailable('#j_id352\\:link','onclick','#j_id352\\:panel','show')</script>

      </a>

       

      To remove this "undesired" effect:

       

      Solution A

      You could set in the h:outputLink the onclick to return false.

      I mean:

           <h:outputLink value="#" id="link" onclick="return false;">

       

      Solution B (recommended)

      RichFaces team has already though of that and RF provides the disableDefault parameter in the rich:componentControl.

      So, just change your code to:

       

      <h:outputLink value="#" id="link">
               Show Modal Panel
               <rich:componentControl for="panel" attachTo="link" operation="show" event="onclick" disableDefault="true" />
      </h:outputLink>

       

       

      Hope it helps,

      Andreas Panagiotidis