diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index bf6eb5d97594b4aa40fa6a3dff91beadd253860c..4e5cea8fb9bf00fa25bfb8b559074a0b84c2f4dd 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Updated docs for in_place_editor, fixes a couple bugs and offers extended support for external controls [Justin Palmer]
+
* Update documentation for render :file. #2858 [Tom Werner]
* Only include builtin filters whose filenames match /^[a-z][a-z_]*_helper.rb$/ to avoid including operating system metadata such as ._foo_helper.rb. #2855 [court3nay@gmail.com]
diff --git a/actionpack/lib/action_controller/macros/in_place_editing.rb b/actionpack/lib/action_controller/macros/in_place_editing.rb
index d096e57e9ee2b252ecf732509a0f6397deacf9bf..30e94c51a975acefa435615b8626217b9e09b061 100644
--- a/actionpack/lib/action_controller/macros/in_place_editing.rb
+++ b/actionpack/lib/action_controller/macros/in_place_editing.rb
@@ -14,7 +14,7 @@ def self.append_features(base) #:nodoc:
# end
#
# # View
- # <%= in_place_editor_field :post, title %>
+ # <%= in_place_editor_field :post, 'title' %>
#
# For help on defining an in place editor in the browser,
# see ActionView::Helpers::JavaScriptHelper.
diff --git a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
index c340468fcba8bb6c459296a1d5b6c689d8f6f7cf..f0fc092572b7070bae73bd86234ff67e282925de 100644
--- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
+++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb
@@ -28,21 +28,23 @@ module JavaScriptMacrosHelper
# be sent after the user presses "ok".
#
# Addtional +options+ are:
- # :rows:: Number of rows (more than 1 will use a TEXTAREA)
- # :cancel_text:: The text on the cancel link. (default: "cancel")
- # :ok_text:: The text on the save link. (default: "ok")
- # :options:: Pass through options to the AJAX call (see prototype's Ajax.Updater)
- # :with:: JavaScript snippet that should return what is to be sent
- # in the AJAX call, +form+ is an implicit parameter
+ # :rows:: Number of rows (more than 1 will use a TEXTAREA)
+ # :cancel_text:: The text on the cancel link. (default: "cancel")
+ # :save_text:: The text on the save link. (default: "ok")
+ # :external_control:: The id of an external control used to enter edit mode.
+ # :options:: Pass through options to the AJAX call (see prototype's Ajax.Updater)
+ # :with:: JavaScript snippet that should return what is to be sent
+ # in the AJAX call, +form+ is an implicit parameter
def in_place_editor(field_id, options = {})
function = "new Ajax.InPlaceEditor("
function << "'#{field_id}', "
function << "'#{url_for(options[:url])}'"
js_options = {}
- js_options['cancelText'] = options[:cancel_text] if options[:cancel_text]
- js_options['okText'] = options[:save_text] if options[:save_text]
+ js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text]
+ js_options['okText'] = %('#{options[:save_text]}') if options[:save_text]
js_options['rows'] = options[:rows] if options[:rows]
+ js_options['externalControl'] = options[:external_control] if options[:external_control]
js_options['ajaxOptions'] = options[:options] if options[:options]
js_options['callback'] = "function(form) { return #{options[:with]} }" if options[:with]
function << (', ' + options_for_javascript(js_options)) unless js_options.empty?
@@ -59,7 +61,7 @@ def in_place_editor_field(object, method, tag_options = {}, in_place_editor_opti
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[:tag], tag_options) +
+ tag.to_content_tag(tag_options.delete(:tag), tag_options) +
in_place_editor(tag_options[:id], in_place_editor_options)
end