Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3032

Show
Ignore:
Timestamp:
11/14/05 20:46:32 (3 years ago)
Author:
xal
Message:

* Updated docs for in_place_editor, fixes a couple bugs and offers extended support for external controls [Justin Palmer] closes #2870

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r3015 r3032  
    11*SVN* 
     2 
     3* Updated docs for in_place_editor, fixes a couple bugs and offers extended support for external controls [Justin Palmer] 
    24 
    35* Update documentation for render :file.  #2858 [Tom Werner] 
  • trunk/actionpack/lib/action_controller/macros/in_place_editing.rb

    r2191 r3032  
    1515      # 
    1616      #   # View 
    17       #   <%= in_place_editor_field :post, title %> 
     17      #   <%= in_place_editor_field :post, 'title' %> 
    1818      # 
    1919      # For help on defining an in place editor in the browser, 
  • trunk/actionpack/lib/action_view/helpers/java_script_macros_helper.rb

    r2537 r3032  
    2929      #  
    3030      # 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 
    3738      def in_place_editor(field_id, options = {}) 
    3839        function =  "new Ajax.InPlaceEditor(" 
     
    4142 
    4243        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] 
    4546        js_options['rows'] = options[:rows] if options[:rows] 
     47        js_options['externalControl'] = options[:external_control] if options[:external_control] 
    4648        js_options['ajaxOptions'] = options[:options] if options[:options] 
    4749        js_options['callback']   = "function(form) { return #{options[:with]} }" if options[:with] 
     
    6062        tag_options = {:tag => "span", :id => "#{object}_#{method}_#{tag.object.id}_in_place_editor", :class => "in_place_editor_field"}.merge!(tag_options) 
    6163        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) + 
    6365        in_place_editor(tag_options[:id], in_place_editor_options) 
    6466      end