1

I want to try using scala.js on a SalesForce project.

SalesForce automatically injects the Visualforce.remoting.Manager.invokeAction(...) function to enable querying data and doing dml.

How can I call this function from scala.js?

2 Answers 2

1

In the crudest sense, you could just invoke it directly from global scope using js.Dynamic, something like:

js.Dynamic.global.Visualforce.remoting.Manager.invokeAction(...)

That works for a one-off, but if you're going to be working more with this Manager, I'd probably recommend creating a Scala.js facade for the Manager, and assigning the Manager object to that -- it'll probably result in better code in the long run.

Sign up to request clarification or add additional context in comments.

Comments

0

You should be able to call any exposed javascript method from scala-js using

scala.scalajs.js.eval(x: String)

Example for calling a bootbox modal:

 import scala.scalajs.js.annotation.JSExportTopLevel
 import scala.scalajs.js

 @JSExportTopLevel("myCallBack")
 protected def confirmCallback() = // do stuff

 def askAQuestion(): Unit = {
    js.eval("bootbox.confirm(\"Your question goes here.\", function(result) { if (result == true) { myCallBack(); }});")
 }

Of course for this to work you have to include the javascript libary in your project.

Since this is a quite messy solution, you might consider writing your own facade.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.