Created
January 11, 2012 08:50
-
-
Save giuseb/1593783 to your computer and use it in GitHub Desktop.
Code that caused the first javascript asset to be loaded twice
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
module ActionView | |
module Helpers | |
module AssetTagHelper | |
# We redefine javascript_include_tag in order to auto-magically include | |
# the widgets javascripts. If you hame more than one javascript_include_tag | |
# call, the widgets javascripts gets included only once. | |
def javascript_include_tag_with_widgets(*sources) | |
unless @__widgets_has_already_included_its_js | |
options = sources.last.is_a?(Hash) ? sources.pop : {} # remove options | |
sources << 'widgets/tooltip' | |
sources << options # add previously removed option | |
@__widgets_has_already_included_its_js = true | |
end | |
javascript_include_tag_without_widgets(*sources) | |
end | |
alias_method_chain :javascript_include_tag, :widgets | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment