Aesis
Aesis

Reputation: 31

Thymeleaf Uncaught SyntaxError: missing ) after argument list

I'm trying to pass an onclick event to Javascript using Thymeleaf but getting "Uncaught SyntaxError: missing ) after argument list".

      <li th:onclick="'radar(' + ${radar} + ', ' + ${radarList} + ');'" th:each="radar : ${radarList}" th:id="${radar.index}">
          <button class="button button_module" th:id="${radar.index}">
              <img th:src="@{/images/icon_module_radar.png}" /><br />
              <span th:text="${radar.name}"/>
          </button>
      </li>


function radar(id, list)
{
    for (var i in list)
    {
        document.getElementById(list[i]['index']).className = "button button_module";
    }
    document.getElementById(id['index']).className = "button button_module_selected";

    setRadarStats(id);
}

I think ${radarList} is passing object to list as intended, but I can't see for sure because I'm getting an error.

Any help is much appreciated. Thanks.

Upvotes: 0

Views: 824

Answers (1)

Periklis Douvitsas
Periklis Douvitsas

Reputation: 2491

can you replace this line of code

th:onclick="'radar(' + ${radar} + ', ' + ${radarList} + ');'"

with

<li th:onclick="'javascript:radar(\'' + ${radar} +'\',\''+ ${radarList} +  '\');'" 

and let me know if this worked for you

Upvotes: 1

Related Questions