Question

I'm trying to do = yield :javascript after an javascript include

so i have in html i have something like this:

<body>
<!-- my actual = yield :javascript of javascript calling my js codes -->
 <script type="text/javascript">//my-js-code</script>

<!-- javascript include tag that contains jQuery -->
<script type="text/javascript" src="path/to/jquery"></script>
</body>

So in my index.html.haml my yield of javascript needs to be placed after this include of jQuery, the problem is that i dont have access to this include of jquery, i need something like this: "select this yield of javascript and put after the script tag that contains and id, for example"

Someone can help?

Obs: i'm using rails 4, ruby 2, and haml

Was it helpful?

Solution

Normally you can order your js files in the application.js via require for example.

So if you need to load some javascript after some other javascript has been loaded, split your js code in different files and load the files in the order you want them to be.

Maybe this Link helps: http://guides.rubyonrails.org/asset_pipeline.html There is a section "2.2 Asset Organization" which might be useful for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top