I need to run a conditional inside a .js.erb file when an ajax call is made.
I have the following:
function updateContent() {
$('.organiser__holder').html('<%= escape_javascript render("filter_links") %>');
$('.houses').html('
<% if @houses.count > 0 %>
<%= escape_javascript render(@houses) %>
<% else %>
<%= escape_javascript '<div class="message-box"><p>No houses matching those parameters</p></div>' %>
<% end %>
');
$('.paginator').replaceWith('<%= escape_javascript(render("shared/house_paginator").to_s) %>');
}
I don't think this is the correct way to accomplish this but not sure what the correct way is?
Anyone have any ideas?