In_place_editor_field submitOnBlur & okButton=false options?

I have a few in_place_editor_fields working fine. I can access some of
the options such as :cols, :save_text, :cancel_text, but
how do I access the okButton = false & submitOnBlur options? Basically,
I want no submit button, a cancel button, and the ability to submit when
I tab out of the field.

Is this doable without writing a helper? (avoiding digging that deep so
early on in my rails learning) wiki shows a variety of options:

If I can pass :save_text onto scriptaculous, why can’t I also pass the
other options as well?

If I can pass :save_text onto scriptaculous, why can’t I also pass
other options as well?

I found a post by Ola B. ( who had posted
a solution that created a new, more extended in_place_editor &
in_place_editor_text helper. It’s probably the way it was displayed in
the webpage, but it had something in the url option that threw an error,
so I removed that option and it started working. I then added the
onBlurSubmit (not Blue as I posted above) option and it was pretty
painless. :slight_smile: The updated code with onBlurSubmit is posted below.

Now that I had access to the other scriptaculous functions, I found that
onBlurSubmit didn’t play well with Safari (2.04). It seems that once I
tab out of the field, it does update the column in the database, but
then it gets locked up in a tight little loop and eventually causes
Safari to quit. Only thing I can think of is that once it looses
focus, it may get focus somehow and then loose it again and back and
forth until it crashes. It seems to work ok in Firefox ( but I
live in Safari so I chose to not use onBlurSubmit. I was able to remove
the submit button with okButton = ‘false’ and that made things look a
lot nicer.

Does anyone know how to change the margins & font of the field itself?
Scriptaculous lists the class of the editing form as
‘inplaceeditor-form’ but any CSS I create only seems to apply to the
cancel text (except for text-decoration or color?!?) and not to the
field itself.

Here is the complete edited helper code that lives in
/helpers/application_helper.rb to extend in_place_editor_field. So you
would now call ‘in_place_editor_field_ext’ to get this new routine:

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 

js_options[‘savingText’] = %(’#{options[:saving_text]}’) if
js_options[‘formClassName’] = %(’#{options[:form_class_name]}’) if
js_options[‘clickToEditText’] =
%(’#{options[:click_to_edit_text]}’) if options[:click_to_edit_text]
js_options[‘highlightcolor’] = %(’#{options[:highlight_color]}’) if
js_options[‘highlightendcolor’] =
%(’#{options[:highlight_end_color]}’) if options[:highlight_end_color]
js_options[‘cancelText’] = %(’#{options[:cancel_text]}’) if
js_options[‘okText’] = %(’#{options[:save_text]}’) if
js_options[‘loadingText’] = %(’#{options[:loading_text]}’) if
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[‘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]
js_options[‘submitOnBlur’] = options[:submit_on_blur] if
function << (’, ’ + options_for_javascript(js_options)) unless
function << ‘)’

def in_place_editor_field_ext(object, method, tag_options = {},
in_place_editor_options = {})
tag =, method, self)
tag_options = {:tag => “span”, :id =>
“#{object}#{method}#{}in_place_editor", :class =>
in_place_editor_options[:url] = in_place_editor_options[:url] ||
url_for({ :action => "set
#{object}_#{method}”, :id =>
tag.to_content_tag(tag_options.delete(:tag), tag_options) +
in_place_editor_ext(tag_options[:id], in_place_editor_options)

This is great! I was going to put together the same thing myself today.
Thanks for saving me some time.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs