I have some variables in javascript:
var something = 1;
var url = "@CSRF(routes.Some.thing(something))";
I get an error during compilation because "something" does not refer to the javascript variable, in other words; the compiler can't identify it. Is it possible to convert/inject the javascript variable somehow? Also, does this work in real time in javascript or do I need to prepare an "@CSRF(routes.Some.thing(something))" array containing each possible "something" value?
It's supposed to be a simple rest call, seen in routes file:
/something/:something controllers.Some.thing(something : Long)
An alternative would be to use a form, but I want to try not to.
somethinglives in user's browser, long after the page has been rendered on the server and sent over the network. Sinceplaycannot see into the future (and also not into user's browser), this doesn't seem to be possible like this. However, you could pre-compute many different routes, and then add some logic in JS to select the right URL on the client side...