I have a page with two fields that are inline-editable. Although both
fields are saved after submitting changes, I can’t get the first field
to display the new value - it always spits our raw js. The 2nd field
works no problem.
I have this in my view:
And the following in my controller:
def update
@photo = @event.photos.find(params[:id])
respond_to do |format|
if @photo.update_attributes(params[:photo])
flash[:notice] = 'Photo was successfully updated.'
format.html { redirect_to(event_photos_url(@event)) }
format.xml { head :ok }
format.js { render :update do |page|
page[:caption].replace_html :partial => 'caption'
page[:tags].replace_html :partial => 'tag_list'
end }
else
format.html { render :action => "edit" }
format.xml { render :xml => @photo.errors, :status =>
:unprocessable_entity }
end
end
end
I’m completely stumped as to why it refreshes the values when updating
the 2nd field (the tags), but not when I update the caption.
This is the js it puts instead of the new caption:
try { $(“caption”).update(“this is a dog of course\n”);
$(“tags”).update(“dog, food, cat, fish”); } catch (e) { alert(‘RJS
error:\n\n’ + e.toString()); alert(’$(“caption”).update(“this is a
dog of course\n”);\n$(“tags”).update(“dog, food, cat, fish”);’);
throw e }
Any ideas?
Thx
Nick