0

Use javascript variable in El Expressions

asked 2017-09-13 23:22:14 +0800

pierpaolocorvese gravatar image pierpaolocorvese
3 1

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.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-15 11:40:18 +0800

cor3000 gravatar image cor3000
3382 1 7
ZK Team

updated 2017-09-15 11:40:34 +0800

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2017-09-13 23:22:14 +0800

Seen: 8 times

Last updated: Sep 15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More