I want to get the variable from javaScript to set in twig variable. For exemple I have a variable "myId" in javaScript and get it to my twig varible.
var myid = 823;
My twig:
{% set = "(myId from JavaScript)" %} {# 823 #}
I want to get the variable from javaScript to set in twig variable. For exemple I have a variable "myId" in javaScript and get it to my twig varible.
var myid = 823;
My twig:
{% set = "(myId from JavaScript)" %} {# 823 #}
Sorry, this won't work (at least out of the box).
Twig templates are rendered serverside without knowledge about Javascript variables, and the javascriptcode is executed on the client after the rendered template has been delivered to the client.
One way to solve this would be with aditional Javascript, render a span with an id in the twig template and update the html content of the span from JavaScript.