Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created October 22, 2009 19:52
Show Gist options
  • Save ajsharp/216240 to your computer and use it in GitHub Desktop.
Save ajsharp/216240 to your computer and use it in GitHub Desktop.
# New way of handling both HTML and AJAX requests RESTfully in the view templates
# Below are the (uncommitted) changes I've made to the contacts views
# contacts/index.html.erb
<%= render :partial => 'patients/patientnav', :locals => {:page => "demographics"} %>
<div id="patient_section" class="casecontent">
<%= render :partial => "index" %>
</div>
<%= render :partial => 'patients/patientnavend' %>
# contacts/_index.html.erb
<div class="panel">
<div class="panelheader" style="z-index:0">
<div class="title">Patient Contacts</div>
<div class="panelheadercontrols" style="top:2px; right: 3px">
<%= button_to_function "Add Contact", "YAHOO.optimis.addOrEditDialog( 'Add Contact', 'patient_section',
'#{ new_patient_contact_path(@patient) }',
'#{ patient_contacts_path(@patient) }');return false;" %>
</div>
</div>
<table width="95%">
# ...
</table>
</div>
# contacts/index.js.erb
jQuery("#<%= params[:dest] %>")
.html("<%= escape_javascript(render :partial => "index") %>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment