1

I have a project using Play Framework as a server and the client written in Scala.js and inserted into the page delivered via scalajs-scripts. There also is a shared sub-project used by both server and client.

Now I want the client to read a value that is dynamically inserted by the server when the page is served. I don't want to do AJAX or recompiling the client.

I'm thinking of using another script tag to define a global variable with value set dynamically by Play and then let the client read it from the global scope, but it is a bit hacky. Is there a better solution? Thanks!

1 Answer 1

1

I'm thinking of using another script tag to define a global variable with value set dynamically by Play and then let the client read it from the global scope, but it is a bit hacky. Is there a better solution?

That is the best solution ;)

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

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.