I recently came across the fact that the imports of bootstrap were not accessible in my code. Namely, the plugin alert for jQuery was not available within my code (jQuery.fn.alert
was undefined). I had in the header:
<script src="@routes.Assets.at("lib/jquery/jquery.min.js")"
type="text/javascript"></script>
<script src="@routes.Assets.at("lib/bootstrap/js/bootstrap.min.js")"
type="text/javascript"></script>
and in the body:
<body>
@playscalajs.html.scripts("client")
</body>
In the client script, when it called $("...").alert()
, I receive the error: alert is not a function
, although I verified bootstrap did define it.
How to make bootstrap and playscalajs work nicely together?
The problem came from
@playscalajs.html.scripts("client")
which is unfold to these:jQuery
is imported again inclient-jsdeps.js
since it is a scala-js dependency. Since I could not interleave bootstrap imports before theclient-launcher.js
script and after theclient-jsdeps.js
scripts, I delayed the execution of the main object using the following code: