Quantcast
Viewing latest article 2
Browse Latest Browse All 2

To verify if the element exists before replacing. (ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods#replace_html)

Just add this code into a initializer file.

Atention: The code starts at the “module ActionView” and the last “end” has to be copied too.

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


Viewing latest article 2
Browse Latest Browse All 2

Trending Articles