Skip to content

Instantly share code, notes, and snippets.

@keppy
Created September 3, 2012 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keppy/3613037 to your computer and use it in GitHub Desktop.
Save keppy/3613037 to your computer and use it in GitHub Desktop.
Ajax call not displaying dynamic content--@invoice_reservations--the partial is rendered though.
<table class="table table-bordered table-striped">
<%= @invoice_reservations.each do |r| %>
<tr>
<td><%= r.name %></td>
</tr>
</table>
def show_client_invoices
if params[:invoice][:company_id] != ""
@company = Client.find(params[:invoice][:company_id])
@invoice_reservations = @company.invoice_reservations
render :partial => 'client_reservations', :content_type => 'text/html'
end
end
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<%= link_to "All Invoices", invoices_path %>
<% @clients.each do |c| %>
<li><%= link_to c.name, show_client_invoices_invoices_path(:invoice => @invoices.first. id, :company_id => "#{c.id}"), :remote => true %></li>
<% end %>
</ul>
</h4></p>
<div id="invoice_list">
<%= render 'invoice_list' %>
</div>
class InvoicesController < ApplicationController
before_filter :require_user
respond_to :js, :html, :json
def show_client_invoices
if params[:invoice] != "" && params[:company_id] != ""
@company = Client.find(params[:company_id])
@invoice_reservations = @company.invoice_reservations
respond_with(@invoice_reservations)
end
end
$("#invoice_list").html("<%= escape_javascript(render(:partial => "client_reservations", :invoice_reservations => :@invoice_reservations))%>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment