@ -28,4 +28,14 @@ module ApplicationHelper
|
||||
%w(Coder live_code)
|
||||
], selected: (val.blank? ? '' : val))
|
||||
end
|
||||
|
||||
# include javascript only once
|
||||
# Allows the safe loading of js dependencies in partials multiple times.
|
||||
def content_for_javascript_once code_label, &block
|
||||
@js_blocks ||= []
|
||||
return if @js_blocks.include? code_label
|
||||
|
||||
@js_blocks << code_label
|
||||
content_for :custom_javascipt, &block
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user