Module: UeditorRails::Helpers::FormHelper

Extended by:
ActiveSupport::Concern
Includes:
ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper
Defined in:
lib/ueditor_rails/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#ueditor_text(object_name, method = nil, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ueditor_rails/helpers/form_helper.rb', line 9

def ueditor_text(object_name, method = nil, options = {})
  instance_tag = ActionView::Base::InstanceTag.new(object_name, method, self, options.delete(:object))
  instance_tag.send(:add_default_name_and_id, options) if options[:id].blank?

  element_id = options.delete('id')
  ue_tag_attributes = {:type => 'text/plain', :id => element_id, :name => options.delete('name')}
  options[:initialFrameWidth] = options.delete(:width) unless options[:width].blank?
  options[:initialFrameHeight] = options.delete(:height) unless options[:height].blank?

  output_buffer = ActiveSupport::SafeBuffer.new
  #output_buffer << instance_tag.to_content_tag(:script, ue_tag_attributes)
  output_buffer << instance_tag.to_text_area_tag(ue_tag_attributes)
  output_buffer << javascript_tag {Util.js_replace(element_id, options.stringify_keys)}
  output_buffer
end