Using Rails 3.2.0 with haml, sass and coffeescript:
Basically I am trying to disable jQuery_Mobile loading pages with ajax without having to include a buch of javascript within any of my views.
I tried this:
13 //= require jquery¬
14 //= require jquery_ujs¬
15 //= require_tree .¬
16 $(document).bind("mobileinit", function() {¬
17 $.mobile.ajaxEnabled = false;¬
18 });¬
19 //= require jquery_mobile¬
with no success, I don’t completely understand the chain of events when = javascript_include_tag "application"¬ is called and what // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD GO AFTER THE REQUIRES BELOW.¬ means?
Anything you put in the application.js manifest file will be executed at the bottom of that file once all other require directives have been run.
What you want is to put this code inside a javascript file (call it
jquery_mobile_startup.js) and put arequire 'jquery_mobile_startup.js'at the top of your file.Sprockets honors the order you put stuff in there and require_tree will not re-import what you already imported.
To expand a bit on this:
application.js is being read as the manifest file for what files to include and when running in production Sprockets/Rails will combine all files that are required in the manifest into one big minified JavaScript file and serve that to your users.
Only in development will the
<%= javascript_include_tag 'application' %>generate multiple tags for you.All require calls will generate a tag and all regular Javascript code will be remain in application.js that gets imported after all imported files (in development).