Search code examples
javascriptjqueryspringcallmessage

Use spring:message from JavaScript


I have a JQuery function who add a Table in the JSP dynamically:

$('#add').click(function(event) {

    event.preventDefault();

$('.tabela_procurador').before
    ('<table id="tabela_nova' + i + '" class="tabela_nova"> ' +
        '<tr> ' +
            '<td colspan="4" class="subTitulo_barra"> ' +
            '<spring:message code="representante_legal" /> '+ i +' ' +
            '</td> ' +
        '</tr> ' +
      '</table>');
     i++
   });
});

But when i added this table i lost the spring:message.

There is something i can do to jquery recognize this spring:message?


Solution

  • There's no way for jQuery to have access to a spring tag. spring:message is processed server-side before the page is sent to the client, javascript/jQuery is processed later on the client side.