1

I have a table in html, filled via a many items. The row's code is this:

<tr th:each="item : ${srcResults}">
    <td th:text="${item.something}"style="vertical-align:middle;" />...
    <td style="vertical-align: middle;">
        <label class="btn btn-primary" title="Details" onclick="submitDetails(${item});">
             <i class="fa fa-info" />
        </label>
    </td>
</tr>

and the javascript function that's called is:

submitDetails = function(item) {
    console.log('I have been called');
};

But It does not work and chrome's console says

Uncaught SyntaxError: missing ) after argument list referring to the label tag.

I have to use the item object but I do not know how to pass it to the js function

1
  • what is the output of ${item}? Commented Feb 2, 2016 at 11:55

1 Answer 1

2

try something like this

onclick="submitDetails('"+${item}+"');"
Sign up to request clarification or add additional context in comments.

1 Comment

I've used this onclick="submitDetails('${item}');" and it worked. Thanks

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.