So I have something that looks like this:
<script>
$(document).ready(function(){
$("button.fadeMeOut").click(function(){
var fadeID = $(this).attr('id');
window.location.href = '@routes.Application.function(fadeID)';
});
});
</script>
Of course this code will give a not found: value fadeID
error. Is there a way for me to do something like this in Play Scala template?
You can not mix Scala variables (server-side) with JS variables (client-side) as they are generated in quite distant environments.
Instead you can use for an example Play's javascriptRoutes
like described in other question
You can insert the relative URL in place of '@routes.Application....etc'
So for example
"/function/" + fadeID
If the route of @routes.Application.function is /function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With