How to fix WebCenter Portal and jquery document ready function not running

Recently came across this issue on Webcenter Portal whenever you use jquery and the document ready function

If this jquery is referenced as an <af:resource source=”jquery-test.js”/> in your page or page template, in certain use cases it will not execute the javascript . One of the instances is when the entire page is loaded via PPR is you navigate to another application and hit the back button. All the jquery javascript code within the ready function will not execute.

ADF renders the following to load javascript resources

When its rendered in a ppr call this does not seem to execute the ready function. The way to fix this is to make sure you include the ready function in the jspx or page fragment.

The ideal way is to invoke this as a declarative component in your page or page template like so

<af:declarativeComponent id=”dc1″ viewId=”jquery.jsff”/>

Then make sure to add the page fragment jquery.jsff like so

Jaideep