播放框架-在Scala模板中使用Javascript变量 [英] Play Framework - Using Javascript Variable in Scala Template

查看:72
本文介绍了播放框架-在Scala模板中使用Javascript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这样的东西:

<script>
$(document).ready(function(){
  $("button.fadeMeOut").click(function(){
      var fadeID = $(this).attr('id');
      window.location.href = '@routes.Application.function(fadeID)';
  });
});
</script>

当然,此代码将给出not found: value fadeID错误.我有办法在Play Scala模板中做类似的事情吗?

Of course this code will give a not found: value fadeID error. Is there a way for me to do something like this in Play Scala template?

推荐答案

您可以插入相对URL代替"@ routes.Application .... etc"

You can insert the relative URL in place of '@routes.Application....etc'

例如 "/function/" + fadeID

如果@ routes.Application.function的路由为/function

If the route of @routes.Application.function is /function

这篇关于播放框架-在Scala模板中使用Javascript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆