Ajax + Format.js = :(

Hi all,

I’m calling a method in my controller like this:
<%= link_to_remote ‘Search’, :url => customers_path + ‘.js’, :with =>
“‘name=’ + $(‘name’).value”, :method => :get, :update => ‘customers’ -
%>

And then updating my page like this:
format.js { render :partial => ‘customers/result’, :collection =>
@customers }

And my app is telling me that the partial doesn’t exist where it
should… However, it does. There is definately a partial in app/
views/customers called _result.html.erb.

Does anyone know what would be causing this?

Heh–I do. Just went through this.

Because you’re calling the partial from the format.js{} block, you’ve
got to name it _result.js.erb. Nevermind that it’s actually HTML what’s
in that file–just call it .js.erb.

(Also–your :url param there looks odd to me–why are you tacking on the
.js suffix? I would think that by virtue of the fact you’re making an
XHR request, that rails’ routing magic would get that done for you…)

HTH,

-Roy