This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= javascript_include_tag 'jquery' %> | |
<%= javascript_include_tag 'rails' %> | |
<%= javascript_include_tag 'application' %> | |
/* NO. NO. The above is /wrong/. */ | |
<%= javascript_include_tag 'jquery' %> | |
<%= javascript_include_tag 'application' %> | |
/* every other javascript file you need */ | |
<%= javascript_include_tag 'rails' %> |
Why? Because your UJS driver is going to hook into the submission events for ajax elements. If you need to run a validation (or anything like it) that has to be executed BEFORE form submission occurs, because it may cancel the submission event, you need to have that code hook into the submission events before your UJS driver does.
Therefore, load your UJS driver last.