1

I have input text box with onkeydown Java script event in my visualforce page. This event will call the java script method and from there action function will call. When action function call, i have initialized the object with data. Display the object data in the panel.

Code snippet:

<apex:inputText value="{!strSearch}" onkeydown="return SetTimer(event);" html-placeholder="Search..." id="txtSearch"/>

function SetTimer(e){
   setTimeout("ReviewSearch()",1000);
}

<apex:actionFunction action="{!ReviewSearch}" name="ReviewSearch" reRender="Activities" status="splashStatus"/>

<apex:outputPanel id="Activities">
     // display activities from controller
</apex:outputPanel>

Now iam getting the performance issue, because how many letters iam typing in text box that many times panel refreshing.

Is there any way to rerender the panel only one time without change the event.

Can anyone help on this.

Thanks,

0

1 Answer 1

1

You need to clear the previous timer, or you'll get multiple calls, spaced one second after the original event:

var timer;
function SetTimer(e){
   if(timer) clearTimeout(timer);
   timer = setTimeout("ReviewSearch()",1000);
}
1
  • Many Thanks for your reply. I have included the above code, but still panel refreshing many times. Commented Oct 30, 2015 at 9:48

You must log in to answer this question.

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