• Lis Witalis
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I have two pages - first one contains iframe component which I'm using to load my second page. I'm using
$('html, body').animate({scrollTop:0}, 'slow');

on my second page but it doesn't work. It works when I'm going directly to my second page (not loaded as a first page's element). How can I fix this?
Here's my Visualforce page:
<apex:page docType="html-5.0" sidebar="false" showHeader="false" standardStylesheets="false" controller="TestController">

    <apex:includeScript value="{! $Resource.jQuery }"/>

    <script type="text/javascript">
        jQuery.noConflict();

        jQuery(document).ready(function() {
            jQuery('[id$=polamonolaa]').bind( "click", function() {
              alert( "Test" );
            });
        })
    </script>

    <apex:form>
        <apex:commandLink action="{!showTest}" value="Show" reRender="panelTest"/>
        <br/>
        <apex:outputPanel id="panelTest">
            <apex:outputPanel id="panelTest2" rendered="{!showTestPanel2}">
                <apex:commandLink id="polamonolaa" reRender="panelTest" value="TOP"/>
            </apex:outputPanel>
        </apex:outputPanel>
    </apex:form>
</apex:page>
Here's my controller:
public class TestController {
    public Boolean showTestPanel2{get;set;}

    public TestController(){
        showTestPanel2 = false;
    }

    public void showTest(){
        showTestPanel2 = true;
    }
}

What I'm trying to do here is to show an alert on a button click. Unfortunately my script doesn't work when button is placed inside outputPanel id="panelTest2" which rendered attribute depends on showTestPanel2 variable. Any suggestions how to fix this issue? Moving my button outside inner panel is not an option.
Here's my Visualforce page:
<apex:page docType="html-5.0" sidebar="false" showHeader="false" standardStylesheets="false" controller="TestController">

    <apex:includeScript value="{! $Resource.jQuery }"/>

    <script type="text/javascript">
        jQuery.noConflict();

        jQuery(document).ready(function() {
            jQuery('[id$=polamonolaa]').bind( "click", function() {
              alert( "Test" );
            });
        })
    </script>

    <apex:form>
        <apex:commandLink action="{!showTest}" value="Show" reRender="panelTest"/>
        <br/>
        <apex:outputPanel id="panelTest">
            <apex:outputPanel id="panelTest2" rendered="{!showTestPanel2}">
                <apex:commandLink id="polamonolaa" reRender="panelTest" value="TOP"/>
            </apex:outputPanel>
        </apex:outputPanel>
    </apex:form>
</apex:page>
Here's my controller:
public class TestController {
    public Boolean showTestPanel2{get;set;}

    public TestController(){
        showTestPanel2 = false;
    }

    public void showTest(){
        showTestPanel2 = true;
    }
}

What I'm trying to do here is to show an alert on a button click. Unfortunately my script doesn't work when button is placed inside outputPanel id="panelTest2" which rendered attribute depends on showTestPanel2 variable. Any suggestions how to fix this issue? Moving my button outside inner panel is not an option.