12

I have an apex:pageBlockSection defined within an apex:component. The component is used within an apex:pageBlock of a Visualforce page. It isn't rendered when the page initially loads.

When a user presses the the arrow on the page block section a JavaScript error is thrown.

Uncaught ReferenceError: twistSection is not defined

twistSection is not defined

Why is this Salesforce JavaScript function missing?

I did find the twistSection function defined on another page. It was defined in a script element of the HTML page (rather than an external script). twistSection function

I guess I could copy this script definition into my component and define the missing function myself if required. My only concern is if when Salesforce updates their script mine will break.

The other backup plan is to put collapsible="false" on the pageBlockSection. Feels a bit like admitting defeat though.

7

As an experiment I added a mock apex:pageBlockSection immediately after the apex:pageBlock on the page.

<apex:page standardController="Account">
    <apex:form>
        <apex:pageBlock title="My Content" mode="edit">

            <!-- HACK: Fake pbSection to inject the twistSection JS function -->
            <apex:pageBlockSection title="Test" showHeader="true" rendered="false">
                <apex:pageBlockSectionItem >
                    <apex:outputText value="Label" />
                    <apex:outputText value="Value" />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>

           <!-- Existing content -->

        </apex:pageBlock>
    </apex:form>
</apex:page>

This seemed sufficient to get Salesforce to inject the missing JavaScript function. Note that it didn't need to be rendered to get the script defined.

2

For me only adding this line worked.

<apex:pageBlockSection title="Test" rendered="false"></apex:pageBlockSection>

I am not sure the collapsable will be deprecated but not sure why doing that. Remember it was working on api 27.0

0

I had this error even when I had the <apex:pageBlockSection> in the code. What helped me was I had the attribute mode="edit" within <apex:pageBlockSection>, when i took it out, it worked fine. Just in case anyone else runs into it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.