I have a remote form, and it submits to the search action. Inside of content#search, I have the following:
respond_to do |format|
#format.html {}
format.js {}
end
I have a search.js.erb file with the following inside of it:
$('#ajaxstuffhere').html("<%= escape_javascript(render :partial => 'search') %>");
Unfortunately this doesn't modify the div in the main page at all.
When I un-comment the format.html {}, it updates the div with search.html.erb content. Unfortunately this renders with the controller's default layout.
What I want is to render this content without the layout. Ideally using javascript, so I can update some Google maps markers along the way.
This form code:
<%= form_tag({:action => 'search'},:id => 'searchForm', :remote => true) do %>
generates this output:
<form accept-charset="UTF-8" action="/search" data-remote="true" id="searchForm" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
Can anyone tell what I'm missing?
Edit: I was thinking ... and if the partial is returned as HTML, I'll be hitting the javascript to catch the response anyways, so I can update the google map in there. Either way is good, so long as the layout is gone (I'd still prefer the js.erb way though).
The server log for the javascript response says the following:
Rendered content/_search.html.erb (270.5ms)
Rendered content/search.js.erb within layouts/content (274.1ms)
But the page doesn't update at all. It seems to be hitting the javascript and the partial seems to be getting called