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…
<%= in_place_editor_field :item, :title %>
<%= @item.date.strftime("%a %d %b %y, %I:%M %p") %>
<%= link_to ‘[Edit]’, :action => ‘edit’, :id => @item %>
<%= link_to ‘[Destroy]’, { :action => ‘destroy’, :id => @item.id },
:confirm => ‘Are you sure?’, :method => :post %>
any idea where i’m going wrong, doing my nut in.
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 G. 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…
<%= in_place_editor_field :item, :title %>
<%= @item.date.strftime("%a %d %b %y, %I:%M %p") %>
<%= link_to ‘[Edit]’, :action => ‘edit’, :id => @item %>
<%= link_to ‘[Destroy]’, { :action => ‘destroy’, :id => @item.id },
:confirm => ‘Are you sure?’, :method => :post %>
any idea where i’m going wrong, doing my nut in.
On 9/19/07, John G. [email protected] 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.
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 S. wrote:
On 9/19/07, John G. [email protected] 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.