I am trying to Update a field on my search result page through in_place_edit and then render a partial to display the updated contents. I am receving the following instead of the real value which is "John Wright" try { Element.update("first_name", "\n \u003Cspan class=\"in_place_editor_field\" id=\"copy_first_name_10115_in_place_editor\"\u003EJohn Wright\u003C/span\u003E\u003Cscript type=\"text/javascript\"\ P.S. If i refresh the page manually i get the correct Values as updated on the page. Following is my the code for the 4 files required to implement 1. The list of search results (view) 2. The controller contating the definition updateattribute 3. The updateattribute.rjs 4. _first_name.html.erb partial # part of view showing search results <table> <%@people.each do |person|%> <tr> <%if params[:first_name]="1"%><div id="first_name"><td><%unless person.first_name.blank?%> <%=@copyofperson = person; in_place_editor_field :copyofperson, :first_name, {}, :url => { :controller => ''person'', :action => ''updateattribute'', :id => person.id } %> <%end%></td></div><%end%> . . . </tr> <%end%> </table> #person controller def updateattribute @person = Person.find(params[:id]) i = params[:editorId] j = i.split("_") j.pop j.pop j.pop j.pop j.delete_at(0) field_name = j.join("_")#Getting the field to be updated in field_name @person.update_attribute "#{field_name}", "#{params[:value]}" end # updateattribute.rjs page.replace_html ''first_name'', :partial=>''first_name'', :object=>@person # _first_name.html.erb <div class ="first_name"> <td><%=@copyofperson = @person; in_place_editor_field :copyofperson, :first_name, {}, :url => { :controller => ''person'', :action => ''updateattribute'', :id => @person.id } %></td> </div> -- 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 -~----------~----~----~----~------~----~------~--~---
On 17 Jul 2008, at 14:56, Ank Ag wrote:> > I am trying to Update a field on my search result page through > in_place_edit and then render a partial to display the updated > contents. > I am receving the following instead of the real value which is "John > Wright" > > try { Element.update("first_name", "\n \u003Cspan > class=\"in_place_editor_field\" > id=\"copy_first_name_10115_in_place_editor\"\u003EJohn > Wright\u003C/span\u003E\u003Cscript type=\"text/javascript\"\ >If I remember correctly, the in place editor is expecting you to return an html fragment it can stick in the DOM, whereas you''re sticking in some JS. There may be some options for customizing that, but I can''t remember off the top of my head. Fred> P.S. If i refresh the page manually i get the correct Values as > updated > on the page. > > Following is my the code for the 4 files required to implement > 1. The list of search results (view) > 2. The controller contating the definition updateattribute > 3. The updateattribute.rjs > 4. _first_name.html.erb partial > > > # part of view showing search results > <table> > <%@people.each do |person|%> > <tr> > > <%if params[:first_name]="1"%><div id="first_name"><td><%unless > person.first_name.blank?%> > <%=@copyofperson = person; in_place_editor_field :copyofperson, > :first_name, {}, :url => { :controller => ''person'', :action => > ''updateattribute'', :id => person.id } %> > <%end%></td></div><%end%> > > . > . > . > </tr> > <%end%> > </table> > > > #person controller > def updateattribute > @person = Person.find(params[:id]) > i = params[:editorId] > j = i.split("_") > j.pop > j.pop > j.pop > j.pop > j.delete_at(0) > field_name = j.join("_")#Getting the field to be updated in > field_name > > @person.update_attribute "#{field_name}", "#{params[:value]}" > > end > > > > # updateattribute.rjs > page.replace_html > ''first_name'', :partial=>''first_name'', :object=>@person > > > > # _first_name.html.erb > > <div class ="first_name"> > <td><%=@copyofperson = @person; in_place_editor_field :copyofperson, > :first_name, {}, :url => { :controller => ''person'', :action => > ''updateattribute'', :id => @person.id } %></td> > </div> > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 17 Jul 2008, at 14:56, Ank Ag wrote: > >> Wright\u003C/span\u003E\u003Cscript type=\"text/javascript\"\ >> > If I remember correctly, the in place editor is expecting you to > return an html fragment it can stick in the DOM, whereas you''re > sticking in some JS. > There may be some options for customizing that, but I can''t remember > off the top of my head. > > > FredCould you please tell me what should i look for on the internet. Or any other alternative to implement in place edit 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 -~----------~----~----~----~------~----~------~--~---