0

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>
1
  • 1
    Try your onclick without the keyword function and just start with setID( Commented Aug 2, 2016 at 15:04

1 Answer 1

1

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})"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.