I have a snippet of javascript which adds classes elements on the page once loaded, I have noticed that while reRendering the page these js changes are lost.

How can I have them reapplied/intact on rerender?

JS Example:

$( document ).ready(function() {        
  • Pls include the page that you are rerendering. Are you rerendering only part of it, or the whole page? Oct 15, 2014 at 13:00

1 Answer 1


Providing this script is not in the part of the page being re-rendered:

// Provide a function that can be used in oncomplete
function myInit() {
    $( document ).ready(function() {        
// Initialise when the page first loads by calling the function

you can invoke the initialisation code after the Ajax request completes by using the oncomplete attribute like this:

<apex:commandButton value="Do Something"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .