I want to perform some AJAX style data retrieval using the Java Play Framework and have come across an issue with the 'route' script syntax.
The problem is that in the code below @{Movies.show("'+movie.id+'")} gets compiled to url/etc/+movie.id+ rather than url/etc/1.
<script type="text/javascript">
function showMoreMovies()
{
$.getJSON('@{Movies.jsonAllMovies()}', function(movies) {
var items = [];
$.each(movies, function(i, movie)
{
var div_data = '<div class="movie">'+
'<h2 class="movie-title"><a href="@{Movies.show("'+movie.id+'")}">'+movie.title+'</a></h2>'+
'<div class="release-date">' + movie.releasedString + '</div>'+
'<div class="comments">| comments: ' + movie.commentCount + '</div>'+
'</div>';
$(div_data).appendTo("#movie_results");
});
});
}
</script>
A work around is to hard-code the route url:
<a href="url/etc/'+movie.id+'">
which works, but you lose the benefits of automatic routing.
Has anyone else come across this or found a new solution to this problem?