我是 Play 框架 (1.2) 的新手,但我想知道并希望我能正确地表达这个问题......我有一个 Play 变量,它存储用户当前正在查看的页面的哪个部分(“_section”)。有没有办法从 .js 函数访问该变量?
更新:
You can store objects for js as well from play:
<script type="text/javascript">
window.mytestarray = new Array();
</script>
#{list 0..links.size()-1, as:'i'}
{%
router = play.mvc.Router;
url = router.reverse(_section + '.' + links[i]).url;
%}
<script type="text/javascript">
window.mytestarray.push("${url}")
</script>
<li js_sub_nav_name="${ _section}" > <!-- MC class="#{if i == 0}first#{/if}"-->
<a href="${url}" class="${lines[i]}#{if _page == links[i]} active#{/if}">&{'header.nav.'+_section+'.'+links[i]+'.html'}</a>
</li>
#{/list}
</ul>
#{/if}