Reputation: 34884
This works well:
<script type="text/javascript">
$(".class1" ).click(function() {
window.location.href = "@routes.MyController.index()"; //OK
})
</script>
But this doesn't:
<script type="text/javascript">
$(".class1" ).click(function() {
window.location.href = "@routes.MyController.show(_: Int)" + getCurrentIdFromHiddenField();
});
</script>
because "@routes.MyController.show(_: Int)"
returns a partially applied function.
I don't want to hard-code the url
, I want to obtain it somehow.
Upvotes: 3
Views: 49
Reputation: 7247
You can use Play's Javascript Router: http://www.playframework.com/documentation/2.2.x/ScalaJavascriptRouting
jsRoutes.controllers.MyController.show(getCurrentIdFromHiddenField())
You'll have to generate the jsRoutes
object, instructions are in the documentation.
Upvotes: 2