Skip to main content

What is the proper pattern for using JavaScript Remoting i.e. @RemoteAction from a Skuid inline JavaScript resource?

Google-Bing led me to this article:
http://sowjitechblog.blogspot.com/2014/05/visualforce-make-remote-action-call.html

Any guidance or code snippets would be appreciated.

Regards,
Irvin

The approach documented under “From a Static Resource” in that article is the proper way to go.

For instance, if your VF Page’s Apex Controller is called “TurboThrusters” and it defines a RemoteAction named “Engage” that expects a single number argument, then your JavaScript would call it like this:

var thursterPower = 50;

TurboThrusters.Engage(thrusterPower,function(result,event){
   if (event.status) {
       console.log(‘Got response back from server okay’);
      console.log(result);
   }
});



Alright, that’s the way I will go.  Thanks!


Also keep in mind that if your code is in a managed package, then you will need to use the Namespace Prefix of that managed package. For instance if your namespace is “galactic”, then you would need to do this:

galactic.TurboThrusters.Engage(thrusterPower,function(result,event){
   if (event.status) {
       console.log(‘Got response back from server okay’);
      console.log(result);
   }
});


Thanks.  You probably just saved me a few minutes of wailing-n-gnashing.


Worked out great.  Thanks again.