Import javascript into html on play 2.0 platform

I am having problems with local javascript files in my html which is on the playback platform. The paths are correct, and I even tried to include the javascript file in the same directory. However, importing from the Internet (the main libraries that I use) works very well.

@(execId: String)

<html>

<head>
<title>Timeline</title>

<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>



<script type="text/javascript"

src="http://code.jquery.com/jquery-latest.js"></script>

<script type = "text/javascript" src = "../../public/javascripts/profilesJS/stack.js">  </script>


</head>


<body>
<input id="profiles" type="button" value="Profiles" />
<script type="text/javascript">
        alert(tester());
    </script>

</body>


</html>

javascript file just looks like it

function tester(){

return "test";

}

And I get the error:

tester is not defined

in the warning line

+5
source share
1 answer

According to the asset documentation (and routing in general), you need to use reverse routing in your template:

<script type="text/javascript" src='@routes.Assets.at("javascripts/profilesJS/stack.js")'></script>

src /public/javascripts/profilesJS/stack.js ( /assets/javascripts/profilesJS/stack.js)

+15

All Articles