A pretty common problem but I haven''t found a solution that works. I''m using in_place_editor_field in my view and all works well when there is data but when the field is blank, I am unable to edit as there is no clickable area. Is there a simple and working solution out there I could make use of? Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
check this out: http://www.akuaku.org/archives/2006/08/in_place_editor_1.shtml --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James Riley
2009-Jan-12 12:10 UTC
Re: in_place_edit_for - non clickable when value is blank
MaD wrote:> check this out: > http://www.akuaku.org/archives/2006/08/in_place_editor_1.shtmlThanks for the response Sadly I''ve already tried this and failed to get it to work, even after working my way through the comments and applying the recommended changes. Even the CSS solution in the most recent comment failed to work as IE6 does not support generated content. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
maybe write something similar yourself (= fix that script with updated code from the plugin) or try to set your default-values to something like "...". what''s your error trace? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
try overriding it like that (i just took the code from github and added an if-clause): def in_place_edit_for(object, attribute, options = {}) define_method("set_#{object}_#{attribute}") do @item = object.to_s.camelize.constantize.find(params[:id]) # adjust the following if-clause to your needs if params[:value].blank? params[:value] = "..." end @item.update_attribute(attribute, params[:value]) render :text => @item.send(attribute).to_s end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James Riley
2009-Jan-15 12:57 UTC
Re: in_place_edit_for - non clickable when value is blank
MaD wrote:> try overriding it like that (i just took the code from github and > added an if-clause): > > def in_place_edit_for(object, attribute, options = {}) > define_method("set_#{object}_#{attribute}") do > @item = object.to_s.camelize.constantize.find(params[:id]) > # adjust the following if-clause to your needs > if params[:value].blank? > params[:value] = "..." > end > @item.update_attribute(attribute, params[:value]) > render :text => @item.send(attribute).to_s > end > endThanks for the response, can you tell me how I''d use the above code? I''ve experimented by creating a file called ''extensions.rb'' within the lib folder, the doing: require ''extensions'' within environment rb. I''ve tried the method on it''s own, followed by placing it within a class wrapper and keep getting errors for ''wrong number of arguments''. My extensions.rb currently looks like this: [code]class Extensions ActionController::Macros::InPlaceEditing::ClassMethods.class_eval do def in_place_edit_for(object, attribute) define_method("set_#{object}_#{attribute}") do @item = object.to_s.camelize.constantize.find(params[:id]) # adjust the following if-clause to your needs if params[:value].blank? params[:value] = "..." end @item.update_attribute(attribute, params[:value]) render :text => @item.send(attribute).to_s end end end end[/code] Thanks for any help -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Don''t know if you found a solution to this but here''s mine: In my database definition I make the default value a ''-'' (or some other non-meaningful value) for a varchar field, or 0 for an int field. My migration to modify existing columns looks like this: <code> class ChangeDefaults < ActiveRecord::Migration def self.up change_column :nodes, :sysName, :string, :null => false, :default => ''-'' change_column :nodes, :ip, :string, :null => false, :default => ''-'' change_column :ports, :vlan, :integer, :null => false, :default => 0 end end </code> With this you don''t need to modify any plugin code. Hope this helps. James Riley wrote:> A pretty common problem but I haven''t found a solution that works. > > I''m using in_place_editor_field in my view and all works well when there > is data but when the field is blank, I am unable to edit as there is no > clickable area. Is there a simple and working solution out there I could > make use of? > > Thanks-- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Oct-02 18:47 UTC
Re: in_place_edit_for - non clickable when value is blank
Colin Wu wrote:> Don''t know if you found a solution to this but here''s mine: In my > database definition I make the default value a ''-'' (or some other > non-meaningful value) for a varchar field, or 0 for an int field.Terrible idea. This is meaningless default data that is only neede for display reasons, and as such has no place in the DB. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.