Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
Can I use thymeleaf syntax inside of javascript code?

Here is the part of the code that I try to take out to .js file

$(document).ready(function () {
$("#buttonCancel").on("click", function () {
    window.location = "[[@{/users}]]"; 
});
});

and link to this file from .html right before close body tag:

<script type="text/javascript" th:src="@{/js/userForm.js?v=1}"></script>

If I click "Cancel" I have an error 400. Yes, I can use "window.location = "/myweb/users";" and it works well. But I am curious if there any way to use th-syntax in javascript file?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As alternative, you could create a hidden link in your HTML, and then use it in your script:

HTML:

<a id="cancelAction" style="display:hidden" th:href="@{/users}"></a>

JavaScript:

$(document).ready(function () {
    $("#buttonCancel").on("click", function () {
        $("#cancelAction").click();
    });
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda