I could use some advice on this situation. I know this looks like a
lot of code, but It is a straightforward implementation question, I am
not stuck or anything. I have what I need working but it involved two
ajax server requests and Im not sure it is the best way. I have a
list of appointments, each with dates and an edit link. This edit
link is a link_to_remote function that makes a call to the server and
renders a partial that replaces the div that contains the appointment
information with editable fields:
I want to make this a ajax request, b/c this is all in an ajaxed popup
and I would like to speed them up by not loading all the editable
field html for every appointment for each popup. Is this a safe
assumption and solution?
The edit_appt action looks like this:
page.replace_html “appt_#{params[:day]}_#{params[:id]}”, :partial =>
‘edit_appt’, :object => @appt_to_edit, :locals => {:day => params
[:day]}
Now if anyone is still with me(and I REALLY appreciate if you are!)
then my question is about placing a cancel link/button in this
edit_appt partial that will load the original appointment. The way it
is set up now is that it makes another ajax request, passes the id
again, performs a search and then renders another partial:
def reload_appt
@appointment = Appointment.find(params[:id])
respond_to do |format|
format.js do
render :update do |page|
page.replace_html “appt_#{params[:day]}_#{params
[:id]}”, :partial => ‘individual_appt’, :object => @appointment,
:locals => {:day => params[:day]}
end
end
end
end
My question is if this is the best way of doing it? Im wondering if
there is some way to use hide/show html or something, b/c the second
database query seems redundant, seeing as how the appointment html
existed in the first place. Thanks for any advice.