# Form search ajax e problema di rendering

**URL:** <https://www.ruby-forum.com/t/form-search-ajax-e-problema-di-rendering/185202>\
**Category:** IT\
**Created:** [March 15, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/form-search-ajax-e-problema-di-rendering/185202 "2010-03-15T23:18:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![msan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@msan](https://www.ruby-forum.com/u/msan)\
**Post date:** [March 15, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/form-search-ajax-e-problema-di-rendering/185202/1 "2010-03-15T23:18:42Z")

</div>

L’index del controller X e’:

def index  
fullname = params[:search].split(" ") if params[:search]  
if fullname  
firstname = fullname[0]  
lastname = fullname[1]  
end  
@rusers = Ruser.search(firstname.to\_s, lastname.to\_s, params[:page])

```
respond_to do |format|
  format.html # index.html.erb
  format.xml { render :xml => @rusers }
end

```

end

la pagina .erb e’:

\<% form\_tag do %\>

\<%= label\_tag :'Cerca nominativo:' %\> \<%= text\_field\_tag :search, params[:search] %\> \<%= image\_tag("indicator.gif", :id =\> "spinner", :style =\> "display: none;") %\>

\<% end %\> \<%= observe\_field(:search, :frequency =\> 0.5, :update =\> :search\_hits, :loading =\> "Element.show('spinner')", :complete =\> "Element.hide('spinner')", :url =\> rusers\_path, :method =\> :get, :with =\> "'search=' + escape(value)")%\>
. . . . .

| First name |
| --- |

In pratica l’index mi mostra un elenco di utenti, se esistono, e un  
form di ricerca tramite ajax.  
Il problema e’ il rendering in quanto in pratica, inserendo dei valori  
nel form, mi viene duplicato il layout all’interno del div  
“search\_hints”  
Non posso mettere nell’action index “render :layout =\> false” in  
quanto mi da un Double Render Error e se metto “render :layout=\> false  
and return if params[:search]”, come suggerito in  
[Layouts and Rendering in Rails — Ruby on Rails Guides](http://guides.rubyonrails.org/layouts_and_rendering.html), torno al  
punto di partenza nel senso che mi viene ripetuto il layout  
all’interno del div.  
Quale soluzione si potrebbe adottare?
