On May 9, 12:58 pm, Werner <[email protected]> wrote:
> What I have: > > #view > <%= text_field_tag :query%> > > <ul id='results'> > <%[email protected] do |client|%> > <li><%= client.name%></li> > <%end%> > </ul> > > #controller > def search > @clients = Client.where("name like ?", "%#{params[:query]} > %").limit(5) > end > > #coffee > jQuery ($) -> > $("#query").change -> > $.get "search", (data) -> > $("#results").html data > > What is happing now is that it lists all names..and if I type in some > letters and click return ..the whole page is getting rendered > again..in the list Your javascript is not actually doing anything with the value of the query text field (take a look at the params received by your code). The get method takes as its optional 2nd argument a map or string of data, ie in your case {query: $(this).val()} (since this is in that event handler, 'this' will be the text field. You also want to ask rails to render without a layout. You can either do this with render :layout => false or you can set the layout at the controller level Fred > > How code it right? > Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

