Play! Framework: Best practice to use URLs in separate JavaScript files?

后端 未结 2 410
栀梦
栀梦 2020-12-29 14:39

I am currently reorganizing a Play! project where there is a lot of JS code in the HTML template files. This code should be moved to external JS files for better readability

2条回答
  •  旧巷少年郎
    2020-12-29 15:29

    In the main template, generate a 'Javascript router', something like:

    
    

    And then in any 'static' javascript file, use this router:

    $.get(routes.doThis({param1: x, param2: 'yop'}))
    

提交回复
热议问题