hello everybody, I have a question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

hello everybody, I have a question

Renato Muniz
it's possible?

<div class="text-center"
    th:text="javascript:functionNames(${name})">
</div>

to call jquery function inside a th: text
this function has text return

tks!
Reply | Threaded
Open this post in threaded view
|

Re: hello everybody, I have a question

Metroids
No, that can't be done.  It's certainly possible to accomplish other ways, but not by calling a javascript function in th:text.

If you're on thymeleaf 3, I would do something like this:

<script>
    function functionNames(text) {
        return text + '!';
    }

    $(function() {
        $('.name').each(function (i, e) {
            $(e).html(functionNames($(e).data('name')));
        })
    });
</script>

<div class="text-center" th:data-name="${name}" class="name" />

(can be simplified, depending on your requirements)


Reply | Threaded
Open this post in threaded view
|

Re: hello everybody, I have a question

Renato Muniz
Yes Metroids, so it works

tks!!