What have you found for these years?

2008-08-21

可惡的 in_place_editing :(

updated:
沒改完整,新版如下:


diff --git a/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb b/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb
index 893e437..5d98081 100644
--- a/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb
+++ b/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb
@@ -62,9 +62,10 @@ module InPlaceMacrosHelper

# Renders the value of the specified object and method with in-place editing capabilities.
def in_place_editor_field(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 })
+ name = object.class.to_s.downcase
+ tag = ::ActionView::Helpers::InstanceTag.new(name, method, self, nil, object)
+ tag_options = {:tag => "span", :id => "#{name}_#{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_#{name}_#{method}", :id => tag.object.id })
tag.to_content_tag(tag_options.delete(:tag), tag_options) +
in_place_editor(tag_options[:id], in_place_editor_options)
end



*

居然假設一定要有同名 instance variable @@
髒啊... 明明可以不用那樣寫的 :(
只好這樣修了:
(參考 action_view/helpers/form_helper.rb: 509,
如果第五 argument 有值,則不取 instance variable.
我乾脆去 fork 一份算了... 不過為什麼這些東西都沒有文件?????)


diff --git a/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb b/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb
index 893e437..7f0dc07 100644
--- a/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb
+++ b/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb
@@ -62,7 +62,7 @@ module InPlaceMacrosHelper

# Renders the value of the specified object and method with in-place editing capabilities.
def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
- tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
+ tag = ::ActionView::Helpers::InstanceTag.new(object.class.downcase, method, self, nil, object)
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) +

0 retries:

Post a Comment

All texts are licensed under CC Attribution 3.0