Hi, I''m kicking my brains around the forecourt, this things is
absolutely driving me to insanity.
Here''s the problem, I''m using the in_place_editor_field to
edit a
reminder''s title and save it, all going good but said item
isn''t getting
updated with the new value; record is but not the view.
here''s the reminder controller code...
--------------------------------------
def list
@reminders = Reminder.find(:all)
end
def set_item_title
@reminder = Reminder.find(params[:id])
@reminder.update_attributes(:title => params[:value])
@reminders = Reminder.find(params[:id])
render :update do |page|
page.replace_html(''item_#params[:id]'', :partial =>
''item'',
:collection => @reminders)
end
#render :nothing => true
#replace_html ''item_'' + @reminder.id, :partial =>
''item'', :object =>
@reminder
end
in the items partial...
-----------------------
<% for @item in @reminders %>
<% if @item.user_id == self.current_user.id %>
<%= render :partial => ''item'' %>
<% end %>
<% end %>
in the item partial...
----------------------
<li id="item_<%= @item.id %>" >
<%= in_place_editor_field :item, :title %><br />
<%= @item.date.strftime("%a %d %b %y, %I:%M %p") %><br
/>
<%= link_to ''[Edit]'', :action =>
''edit'', :id => @item %>
<%= link_to ''[Destroy]'', { :action =>
''destroy'', :id => @item.id },
:confirm => ''Are you sure?'', :method => :post %>
</li>
any idea where i''m going wrong, doing my nut in.
--
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
-~----------~----~----~----~------~----~------~--~---
Bingo! render :update do |page| page.replace ''item_'' << params[:id], :partial => ''item'', :object => @item end ok, it''s not pretty and i don''t know why + or #params[:id] wouldn''t work in the string. if anyone''s got any ideas that''d be great gonna go home to an ice cold beer now, ughh....... John Griffiths wrote:> Hi, I''m kicking my brains around the forecourt, this things is > absolutely driving me to insanity. > > Here''s the problem, I''m using the in_place_editor_field to edit a > reminder''s title and save it, all going good but said item isn''t getting > updated with the new value; record is but not the view. > > here''s the reminder controller code... > -------------------------------------- > > def list > @reminders = Reminder.find(:all) > end > > def set_item_title > @reminder = Reminder.find(params[:id]) > @reminder.update_attributes(:title => params[:value]) > > @reminders = Reminder.find(params[:id]) > render :update do |page| > page.replace_html(''item_#params[:id]'', :partial => ''item'', > :collection => @reminders) > end > #render :nothing => true > #replace_html ''item_'' + @reminder.id, :partial => ''item'', :object => > @reminder > end > > > in the items partial... > ----------------------- > > <% for @item in @reminders %> > <% if @item.user_id == self.current_user.id %> > <%= render :partial => ''item'' %> > <% end %> > <% end %> > > in the item partial... > ---------------------- > > <li id="item_<%= @item.id %>" > > <%= in_place_editor_field :item, :title %><br /> > <%= @item.date.strftime("%a %d %b %y, %I:%M %p") %><br /> > > <%= link_to ''[Edit]'', :action => ''edit'', :id => @item %> > <%= link_to ''[Destroy]'', { :action => ''destroy'', :id => @item.id }, > :confirm => ''Are you sure?'', :method => :post %> > </li> > > > any idea where i''m going wrong, doing my nut in.-- 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 9/19/07, John Griffiths <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Bingo! > > render :update do |page| > page.replace ''item_'' << params[:id], :partial => ''item'', :object => > @item > end > > ok, it''s not pretty and i don''t know why + or #params[:id] wouldn''t work > in the string. > > if anyone''s got any ideas that''d be greatRails has a helper that generates the controller method for you. You would add: in_place_edit_for :item, :title Also, in_place_editor_field generates an Ajax.Updater, so the render :update is not really appropriate. From the docs for in_place_editor, "..the action on the server should process the value and return the updated value in the body of the reponse" Using in_place_edit_for in your controller takes care of that for you. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
tried using that, wouldn''t work, i''ll have a bash at it again next time i''m working on it, right now i''m just glad it works. but thanks Bob, appreciate it, ;-) Bob Showalter wrote:> On 9/19/07, John Griffiths <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> if anyone''s got any ideas that''d be great > > Rails has a helper that generates the controller method for you. You > would add: > > in_place_edit_for :item, :title > > Also, in_place_editor_field generates an Ajax.Updater, so the render > :update is not really appropriate. From the docs for in_place_editor, > > "..the action on the server should process the value and return the > updated value in the body of the reponse" > > Using in_place_edit_for in your controller takes care of that for you.-- 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 -~----------~----~----~----~------~----~------~--~---