Skip to content
This repository
Browse code

stable merge of 3032 -- Updated docs for in_place_editor by Justin Pa…

…lmer

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3071 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 0023cb1b8cf0cec12199250293a2038f63c0bd1f 1 parent 37664eb
Tobias Lütke authored
2  actionpack/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* Updated docs for in_place_editor, fixes a couple bugs and offers extended support for external controls [Justin Palmer]
  4 +
3 5 * Rename Version constant to VERSION. #2802 [Marcel Molina Jr.]
4 6
5 7 * Remove the unused, slow response_dump and session_dump variables from error pages. #1222 [lmarlow@yahoo.com]
2  actionpack/lib/action_controller/macros/in_place_editing.rb
@@ -14,7 +14,7 @@ def self.append_features(base) #:nodoc:
14 14 # end
15 15 #
16 16 # # View
17   - # <%= in_place_editor_field :post, title %>
  17 + # <%= in_place_editor_field :post, 'title' %>
18 18 #
19 19 # For help on defining an in place editor in the browser,
20 20 # see ActionView::Helpers::JavaScriptHelper.
20 actionpack/lib/action_view/helpers/java_script_macros_helper.rb
@@ -28,21 +28,23 @@ module JavaScriptMacrosHelper
28 28 # be sent after the user presses "ok".
29 29 #
30 30 # Addtional +options+ are:
31   - # <tt>:rows</tt>:: Number of rows (more than 1 will use a TEXTAREA)
32   - # <tt>:cancel_text</tt>:: The text on the cancel link. (default: "cancel")
33   - # <tt>:ok_text</tt>:: The text on the save link. (default: "ok")
34   - # <tt>:options</tt>:: Pass through options to the AJAX call (see prototype's Ajax.Updater)
35   - # <tt>:with</tt>:: JavaScript snippet that should return what is to be sent
36   - # in the AJAX call, +form+ is an implicit parameter
  31 + # <tt>:rows</tt>:: Number of rows (more than 1 will use a TEXTAREA)
  32 + # <tt>:cancel_text</tt>:: The text on the cancel link. (default: "cancel")
  33 + # <tt>:save_text</tt>:: The text on the save link. (default: "ok")
  34 + # <tt>:external_control</tt>:: The id of an external control used to enter edit mode.
  35 + # <tt>:options</tt>:: Pass through options to the AJAX call (see prototype's Ajax.Updater)
  36 + # <tt>:with</tt>:: JavaScript snippet that should return what is to be sent
  37 + # in the AJAX call, +form+ is an implicit parameter
37 38 def in_place_editor(field_id, options = {})
38 39 function = "new Ajax.InPlaceEditor("
39 40 function << "'#{field_id}', "
40 41 function << "'#{url_for(options[:url])}'"
41 42
42 43 js_options = {}
43   - js_options['cancelText'] = options[:cancel_text] if options[:cancel_text]
44   - js_options['okText'] = options[:save_text] if options[:save_text]
  44 + js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text]
  45 + js_options['okText'] = %('#{options[:save_text]}') if options[:save_text]
45 46 js_options['rows'] = options[:rows] if options[:rows]
  47 + js_options['externalControl'] = options[:external_control] if options[:external_control]
46 48 js_options['ajaxOptions'] = options[:options] if options[:options]
47 49 js_options['callback'] = "function(form) { return #{options[:with]} }" if options[:with]
48 50 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
59 61 tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
60 62 tag_options = {:tag => "span", :id => "#{object}_#{method}_#{tag.object.id}_in_place_editor", :class => "in_place_editor_field"}.merge!(tag_options)
61 63 in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object}_#{method}", :id => tag.object.id })
62   - tag.to_content_tag(tag_options[:tag], tag_options) +
  64 + tag.to_content_tag(tag_options.delete(:tag), tag_options) +
63 65 in_place_editor(tag_options[:id], in_place_editor_options)
64 66 end
65 67

0 comments on commit 0023cb1

Please sign in to comment.
Something went wrong with that request. Please try again.