Reputation: 20460
I'm using play-1.2.4, but i found the javascript file can't generate urls with the tag:
@{Users.login()}
Indeed i can use
/Users/login
instead , but it will cause problems when i export to war files and run it in tomcat.
Upvotes: 0
Views: 317
Reputation: 54914
Take a look at the JSAction tag. http://www.playframework.org/documentation/1.2/ajax
The purpose of the jsAction tag is to be able to generate the URLs that you need to call from the routes file. However, these need to be defined inside of your views, as they need to be generated serverside by Play, and not inside a js file.
If you really want to be able to keep most of your code inside of your JS file, then you can generate the method names in your main.html file, and reference from within your javascript file.
example
<script type="text/javascript">
var loginAction = #{jsAction @User.login() /}
</script>
then you can access this using
loginAction;
Upvotes: 2