We are currently in the process of refactoring our site and we have decided to just go with one js library (jquery). Problem is, due to time constraint, we can only do so much so at the moment, we have to make them coexist.
This is easy since we have jquery's no conflict method, so I can just declare jquery then do the no conflict thing and then add prototype like so:
<%= javascript_include_tag "jquery" %>
<%= yield :jquery %>
<%= javascript_include_tag "prototype", "effects", "dragdrop", "controls", "lowpro", "neo", "filter", "slider", "calendar", "application", 'alerts' %>
I then just call content_for(:jquery) whenever I need to add a specific jquery js file(this has the no conflict function) on the partial that needs it. So no problem there.
Problem is when you include 2 partials with different jquery files. Only one of them gets called since a content_for jquery is already called, it won't be called anymore(so lets say in a.rhtml, i added a.js and in b.rhtml i added b.js, only a.js will be included)
One solution would be to just include everything in one master js file but that would be difficult to maintain since every function is there etc. Is there a way so I can just append to content_for when it already has been called?
I just checked the api:
http://apidock.com/rails/v2.3.8/ActionView/Helpers/CaptureHelper/content_for
it seems content_for actually APPENDS. But what happens to mine is it just doesn't append/clear out. It just completely ignores the second content_for call