function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How can I call a jQuery function after a ReRender?

Hi Guys,


I'm working through some app development and I've hit a snag. I have some jQuery code which is called using the .ready() function in jQuery. This all works fine until the point I have a ReRender and the DOM is redrawn my code no longer works.


Here's my page:



<apex:page standardController="Handover__c" extensions="HandoverExtension" sidebar="false">
	<apex:includeScript value="{!URLFOR($Resource.JQueryUI, 'jQueryUI/js/jquery-1.5.1.min.js')}"  />
		$j = jQuery.noConflict();
				if($j(this).text().length > 40){
					$j(this).attr("title", $j(this).attr("href"));
					$j(this).text("Long URL Replaced");
	<apex:form >
<apex:outputpanel id="ItemLists">
	<apex:pageblock title="Handover Items" mode="detail">
            <apex:actionStatus id="updateStatus">
       		<apex:facet name="start">
       			<apex:outputPanel >
       				<apex:image url="/img/loading.gif"/>
       				<apex:outputtext value=" Working..."/>
		<apex:pageblocktable value="{!Items.handoveritems}" var="i">
				<apex:commandLink action="{!i.activate_deactivate}" rerender="ItemLists" rendered="{!NOT(Items.hasActivate)}" status="updateStatus"> 
					<apex:image url="{!URLFOR($Resource.handover_images, 'HandoverImages/Delete.png')}" alt="Deactivate this Handover Item" title="Deactivate this Handover Item"/>
			<apex:column Headervalue="Summary" styleClass="ItemTextCol">
				<apex:outputField value="{!i.item.Summary__c}" styleClass="ItemText"/>
			<apex:column headerValue="Current Status" >
				<apex:outputField value="{!i.item.Current_Status__c}" />

Now this all works until the point where I click on the CommandLink and there is a partial page refresh.  


Anyone know what I can do here? 


How can I call the jQuery code again after the partial page refresh? 



Try using the oncomplete attribute.


It's in the docs here:

Prafull G.Prafull G.

put your onready event 's code with in the function and then use this function within the onready event and call the same at commandlink's onComplete action.


something like


document.ready(function()  {




function sampleMethod() {// your code here}


<apex:commandLink action="{!i.activate_deactivate}" rerender="ItemLists" rendered="{!NOT(Items.hasActivate)}" status="updateStatus" onComplete="sampleMethod();">

Hi crmtech,


I had a similar scenario. And your suggestion helped to fix it.

Thank you :-)