-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi at all, I need to initialize a javascript array using an array already initialized in a controller. I though to initialize the javascript array using the EL Expressions but I'm not able to use the index declared in javascript (I obtain this error when i try to open the window "Uncaught SyntaxError: Unexpected token ;") in the EL Expressions. Do you know how to resolve this problem or have any suggestion? Below the code, I hope it helps to clarify my problem:
<script type="text/javascript">
<![CDATA[
for(var index=0; index<1000;index++){
var value =
${ha.leftBust[index][0]};
console.log("value: "+value);
} ]]>
</script>
Thanks in advance.
Hi Pier,
unfortunately that's not how it works. The EL variable is replaced only once at server side. When the client side script runs it can't evaluate again.
What you can do is output a whole js array String from an EL variable and then iterate over the js array as shown in this example.
Robert
Asked: 2017-09-13 23:22:14 +0800
Seen: 14 times
Last updated: Sep 15 '17
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found