Kyle H. wrote:
<%= in_place_editor_field :platform, :name %>
I’ve tried various forms of these options:
<%= in_place_editor_field :platform, :name, {}, { :highlightcolor =>
“#EAEAEA” } %>
<%= in_place_editor_field :platform, :name, {}, { “highlightcolor” =>
“#EAEAEA” } %>
<%= in_place_editor_field :platform, :name, {}, :in_place_editor_options
=> { :highlightcolor => “#EAEAEA” } %>
Hi,
As another person noted; these aren’t supported by Rails yet. I actually
did a quickie and just created my own in_place_editor_field_ext in my
application_helper. This is the full code adding support for all the
interesting InPlaceEditor-helpers. Hmm. Maybe I should submit this code
to the core?
def in_place_editor_ext(field_id, options = { })
function = “new Ajax.InPlaceEditor(”
function << "‘#{field_id}’, "
function << “‘#{url_for(options[:url])}’”
js_options = {}
js_options[‘okButton’] = options[:ok_button] if options[:ok_button]
js_options[‘cancelLink’] = options[:cancel_link] if
options[:cancel_link]
js_options[‘savingText’] = %(‘#{options[:saving_text]}’) if
options[:saving_text]
js_options[‘clickToEditText’] = %(‘#{options[:click_to_edit_text]}’)
if options[:click_to_edit_text]
js_options[‘highlightcolor’] = %(‘#{options[:highlight_color]}’) if
options[:highlight_color]
js_options[‘highlightendcolor’] =
%(‘#{options[:highlight_end_color]}’) if options[:highlight_end_color]
js_options[‘cancelText’] = %(‘#{options[:cancel_text]}’) if
options[:cancel_text]
js_options[‘okText’] = %(‘#{options[:save_text]}’) if
options[:save_text]
js_options[‘loadingText’] = %(‘#{options[:loading_text]}’) if
options[:loading_text]
js_options[‘rows’] = options[:rows] if options[:rows]
js_options[‘cols’] = options[:cols] if options[:cols]
js_options[‘size’] = options[:size] if options[:size]
js_options[‘externalControl’] = “‘#{options[:external_control]}’” if
options[:external_control]
js_options[‘loadTextURL’] = “‘#{url_for(options[:load_text_url])}’”
if options[:load_text_url]
js_options[‘ajaxOptions’] = options[:options] if options[:options]
js_options[‘evalScripts’] = options[:script] if options[:script]
js_options[‘callback’] = “function(form) { return #{options[:with]}
}” if options[:with]
function << (', ’ + options_for_javascript(js_options)) unless
js_options.empty?
function << ‘)’
javascript_tag(function)
end
def in_place_editor_field_ext(object, method, tag_options = {},
in_place_editor_options = {})
tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
tag_options = {:tag => “span”, :id =>
“#{object}#{method}#{tag.object.id}in_place_editor", :class =>
“in_place_editor_field”}.merge!(tag_options)
in_place_editor_options[:url] = in_place_editor_options[:url] ||
url_for({ :action => "set#{object}_#{method}”, :id => tag.object.id })
tag.to_content_tag(tag_options.delete(:tag), tag_options) +
in_place_editor_ext(tag_options[:id], in_place_editor_options)
end
–
Ola B. (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)
“Yields falsehood when quined” yields falsehood when quined.