JavaScript inline link expression query parameter

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

JavaScript inline link expression query parameter

kesavkolla
I have the following code:

<script th:inline="javascript">

var pageURL = [[@{'/page/detail(var=${book.id})']];

</scirpt>

The query parameter is not getting substituted.  Any workarounds for this?
Reply | Threaded
Open this post in threaded view
|

Re: JavaScript inline link expression query parameter

danielfernandez
Administrator
That's because you're including your parameter substitution inside the literal (surrounded by quotes):

Instead of:

    var pageURL = [[@{'/page/detail(var=${book.id})'}]];

Try:

    var pageURL = [[@{'/page/detail'(var=${book.id})}]];

In this case, there is no real need to specify the page as a literal, you can also remove the quotes:

    var pageURL = [[@{/page/detail(var=${book.id})}]];

And be careful: your example was lacking the last "}", which I included in this examples.

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: JavaScript inline link expression query parameter

kesavkolla
Thanks it worked.