I’m building a webapp with jQuery, which is using many $.get(..) and $.post(..) action-calls to my Play Controllers.
Example:
$.get('@{Patients.activeEpisodes()}', function(data) {
$('#secondary').append(data);
});
When I create a javascript function directly in my template file, the @{Controller.action()} tags are correctly replaced with the correct url.
But when i put the same function inside a seperate .js file which is imported in the template using the #{script ‘myJavaScriptFile.js’ /} tag, these @{xxx} tags are not repalced with the correct Url’s.
Is there a way to have these tags properly replaced by the templating enginge?
Thanks for your answer!
Richard
No, the templating engine will only work with the Play Templates. External *.js files are ignored as they are considered to be Javascript files which require no processing.
The only solution is to put that code in the template (or hardcode the path)