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:

<div id="appt_<%= day %>_<%= appointment.id %>"
class="individual_appt">
<%= appointment.end_time.strftime("%l:%M%p").sub(/^0/,'')  %>
<%= link_to_remote "Edit", :url => {:action => "edit_appt", :id =>
appointment.id, :day => day} %>
</div>

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.


--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to