0

Currently I am calling the .retrieve() method on a keypress for a typeahead functionality.

I have faked the code so that when user pauses typing I then fire the call using setTimeout, but the issue is the fetch is 500ms extra, I am ok with that for now but for smooth streaming of data I want to call the AJAX on keypress and if user is still typing I want to abort that call.

A pseudo representation of what I am currently doing

onkeypress = {

   if(setTimeout is set){
       cancel existing timer;
   } 
   setimeout(Remoting(new Value keypress), 500)
}

What I want

onkeypress = {

   if(isRemoting call Dispatched){
       remotingCall.abort() // >> I need this
   } 
   Remoting call(new Value keypress)
}
0

There is no abort functionality that I know of but ...

a simple solution for this can be to only go for the retrieve after the first (or first two) characters are typed in and then filter on the returned list in JS.

You would have to consider that the limitation right now is 100 records per request so you'd have to use OFFSET and retrieve more data whenever the typed string does not have any matched in the already retrieved list.

Hope this makes sense!

If you are using VF RemoteObjects and AngularJS have a look at this little library ngRemote which generates AngularJS services for each defined RemoteObject.

Hope this helps!

Florian

  • 100 records per request limit is for RemoteObjects and not for Visualforce remoting. Visualforce remoting has a limit for response size which is 15 MB. Also other apex limits apply. – ajinkyah May 6 '16 at 6:22
  • But here we are talking about VF RemoteObjects, not JS Remoting... – Florian Hoehn May 9 '16 at 13:40

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.