1

I have to load JS files in order in a rails view. In the rails view I have:

<%= javascript_include_tag "diagrams" %>

The diagrams.js manifest file have the required JS files in the order that is needed:

//= require diagramtool/kinetic
//= require diagramtool/diagramtool0
//= require diagramtool/diagramtool1
//= require diagramtool/diagramtool2

But they are not load in the order specified in the diagrams.js file.

enter image description here

I already have removed the require_tree . in the application.js file.

What do I have to do to load the JS files in a specific order?

Edit1: Every time I click in the view I get different results (it seems random):

enter image description here

enter image description here

enter image description here

enter image description here

I don't really understand what is going on here!! Is that difficult in Rails to load JS files in order? I have read some things about the asset pipeline and I don't understand this random behaviour. If I refresh the page always works, the files are always loaded in order. Any help?

Edit2: The view source is like this: enter image description here

Mario
  • 1,213
  • 2
  • 12
  • 37
  • Have you tried putting //require_self after you list the other scripts? This SO article may help: http://stackoverflow.com/questions/6149961/rails-3-1-asset-pipeline-and-manually-ordered-javascript-requires – BrMcMullin Oct 27 '14 at 18:19
  • Thanks @BrMcMullin! Yes I have tried with //require_self and I get the same result. Any other ideia why is this happening? – Mario Oct 27 '14 at 18:26
  • 1
    But the view source pic you show here has your js files in the correct order. They should always load in the same order. Maybe you're having a problem with Turbolinks. Try removing that from your application.js file. – DiegoSalazar Oct 27 '14 at 18:30
  • Thanks @diego.greyrobot! It works properly with the Turbolinks turned off. Do you have any idea why is this happen when the Turbolinks are on? – Mario Oct 28 '14 at 11:30

0 Answers0