Search code examples
javascriptjquerythymeleaf

Combine JQuery with Thymeleaf


I have this JQuery function used in a Thymeleaf template to submit the template to a specific URL, based on the value selected in a dropbox object, but it seems not to work

$('#selectAuthorizedDriverId').change(
       function() {
            var link = /*[[@{/deviceDriver/updateauthorizeddriver}/$('#selectAuthorizedDriverId').val();]]*/ "";
            $('#deviceFormId').attr('action', link);
            $('#deviceFormId').submit();
    });

Solution

  • Do not use thymeleaf

    var link = "/deviceDriver/updateauthorizeddriver/" + $(this).val();