I am new to playframework and to web programming, so the mixing of play variables, javascript and html is still a bit confusing for me.
In my case, I have a list of objects alarms: List[Alarm]
coming from the controller of the view and I want to access one of the items of the list, but given that the index
of the item come from a javascript function. Is that even possible?
I've tried the code below, but play's compiler do not understand the value of index in @{alarms(index).Patient.name}
. Is there a way to do that? Or is it impossible because the list object is just used during the page creation and it cant be accessed later on by the javascript in a dynamic fashion.
@(alarms: List[Alarm], alarmForm: Form[Alarm])
@import helper._
@main("Alarm list") {
<script id="showInfoScript" language="javascript" type="text/javascript">
function showInfoFromAlarm(index) {
$("#patientName").text(@{alarms(index).Patient.name});
};
</script>