Reputation: 83
Can anyone check my code?
I don't know what happend but I got Uncaught SyntaxError: Invalid or unexpected token
at one of my templates.
<script type="text/javascript" nonce="templates-random-id">
@templates.map { t =>
$('#[email protected]').click(function() {
document.getElementById('text').value = '@t.content';
});
}</script>
I use it for loading a templates from database.
@templates.map { t =>
<button type="button" class="btn btn-default" id="[email protected]">@t.template_name</button>
}
What i got from the source in browser:
$('#template-17').click(function() {
document.getElementById('text').value = 'blablabla blablablablablab lablablablabl ablablablablabla;';
});
Edit: I will try change '@t.content'
to @t.content
with `.
Maybe it will help.
Upvotes: 0
Views: 743
Reputation: 315
This is probably because of @t.content
which contains special symbols.
This fix might apply to your problem as well Escape a JavaScript string in Play 2.0 view?.
Upvotes: 1