Reputation: 45
I want to pass a field of a domain object to a javascript function in my view.gsp (grails) , but I am getting a syntax error.
Here is my gsp and javascript - please let me know if you see the syntax error. Thanks!
/*HTML*/
<td><a href='#' data-toggle="popover" id="popoverID" onclick="function setID( ${studentInstance.id})">${fieldValue(bean: studentInstance, field: "active")}</a></td>
/*JS*/
<script type="text/javascript">
var id = 0;
function setID(userId){
console.log("userId: " + userId);
id = userId;
}
</script>
Upvotes: 0
Views: 367
Reputation: 24776
The issue is you have function
in your onclick
. You don't need it there. Remove it so your onclick
looks like this:
onclick="setID( ${studentInstance.id})"
Upvotes: 1