javascriptRouter
views.html.helper.javascriptRouter
object javascriptRouter extends BaseScalaTemplate[Appendable, Format[Appendable]], Template3[String, Array[JavaScriptReverseRoute], RequestHeader, Appendable]
Attributes
- Graph
-
- Supertypes
- Self type
-
javascriptRouter.type
Members list
Value members
Concrete methods
def apply(name: String)(routes: JavaScriptReverseRoute*)(implicit request: RequestHeader): Appendable
Generates a Javascript object that lets you refer to your application's routes in Javascript code
Generates a Javascript object that lets you refer to your application's routes in Javascript code
Example:
@javascriptRouter("jsRoutes")(
routes.javascript.Users.list,
routes.javascript.Application.index
)
You can access your routes in JavaScript without hardcoded URL's, e.g. assuming jQuery's ajax function:
$.ajax(jsRoutes.controllers.Users.list()).done( /* */ ).fail( /* */ )
Each action in the generated object also has the following properties:
- type: HTTP method
- url: the url to be used
Value parameters
- name
-
The javascript object name.
- routes
-
Set of routes to include in this javascript router.
Attributes
In this article