Topic: Some help with AJAX

I'm trying to make an in_place_edit_field work.  Normally, I name the :symbols by the object and method, but in this case i couldn't (in_place... :template, :name, but @template is a rails instance variable I think. so i have it named  in_place... :mytemplate, :name)  I tried to write a set_mytemplate_name method because thats what the form was looking for, but I'm having trouble figuring out how to access the information in the edit box and store it.

Re: Some help with AJAX

If you view the source of in_place_edit_for you can see what the method should do. In this case try:

def set_mytemplate_name
  @mytemplate = Template.find(params[:id])
  @mytemplate.update_attribute(:name, params[:value])
  render :text => @mytemplate.name
end

Railscasts - Free Ruby on Rails Screencasts

Re: Some help with AJAX

I'm having a little trouble working with AJAX, here is the situation:


Here is a Partial inside an updating div:

Add Link

<div editdesktop>
</div>

:

When the add link is clicked, it is supposed to hide and the form for the new object appears in editdesktop (looks like the same place on screen).  The problem I'm having is after the form is either submitted or canceled the partial is re-rendered.  But now,  the add link does not dissappear when I click on it, but it still works.


I've had this happen in several cases.  Any explanation or fix would be appreciated.

P.S. I did figure out that I could manipulate the add link when its outside of the partial, by showing and hiding, but I still want to know why the above will not work.