....
....
....
<script>
$(function() {
$('#jstree_sch').jstree({
"plugins": ["checkbox", "contextmenu"],
"checkbox": {
"visible": true,
"whole_node": true,
"keep_selected_style": false,
"three_state": true
},
"core": {
"animation": 0,
"check_callback": true,
"themes": {
"stripes": true
},
"data": @if (tree == null) { "nothing" } else { @Html(tree) }
}
});
});
</script>"data": @if (tree == null) { "nothing" } else { @Html(tree) }var mid = @mapobj.id.toString;
On Thu, Jul 16, 2015, 6:10 PM Slim Slam <slima...@gmail.com> wrote:
It doesn't appear that any of the Scala that is now inside JS files (as described above) is getting replaced.
There are no obvious errors until the JS is executed and then I see JS syntax errors from lines like:
var mid = @mapobj.id.toString;
Is there something I'm missing here? Doesn't Twirl instantiate the Scala vars whether the Scala is directly in the Scala template or
whether it's inside a JS file that's included by the template?
Clearly not, right?
A script tag is not an "include." It's something the browser interprets.
The good news is that just like twirl can compile .scala.html files, it can compile .scala.js files.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2408614b-a586-4373-9f78-aee0ff9b4df0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[error] /mycode/app/views/tree.scala.js:44: '(' expected but ')' found.
[error] "data": @if (tree == null) { "nothing" } else { @Html(tree) }<script>var myGlobalVar = @someScalaVar</script>"data": @if (tree == null) { "nothing" } else { @Html(tree) }"data": @if(tree == null) { "nothing" } else { @Html(tree) }
The only difference is the space between "if" and the left paren.Twirl needs a parameter declaration
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/dbfa9f73-aa89-4e39-82dd-02ac80b3eeda%40googlegroups.com.