Ok so I have a template in Play! that receives a List as a parameter:
@(actions : List[RecipientAction])
RecipientAction is just a regular case class with a couple of fields. Within the template, I have a <script>
tag where I want to use D3 to make a line chart. Inside the script I want to populate a JavaScript array with objects that contain the properties stored in RecipientAction in order to use them for my line chart later. I currently have this code:
testArray2=[];
for(var i=0; i < @actions.length;i++){
testArray2[i]= {};
testArray2[i].eventAt= @actions(i).eventAt.toString();
testArray2[i].action= @actions(i).action.id;
}
When i run it, i get the error "not found: value i". This is because i
is a client side variable while actions
is a server side variable, so scala cannot find i
. What would be the best way to work around this and successfully populate the array?