cirandas.net

ref: master

config/initializers/replace_html_if_exists.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#from http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods/replace_html
module ActionView
  module Helpers
    module PrototypeHelper
      class JavaScriptGenerator #:nodoc:
        module GeneratorMethods
          def replace_html_if_exists(id, *options_for_render)
            call "if($('#{id}')) Element.update", id, render(*options_for_render)
          end
        end
      end
    end
  end
end