Problem with observer_field

Hello,

i’m having a problem with my observer_field, i tried to make a live
search wich worked at the beginning but stopt working without making
changes.

this is my code in the controller:
def search_fields
@phrase = params[:phrase] || request.raw_post ||
request.query_string || “”
@imotemplate = Imotemplate.find(params[:template_id])
if 0 == @phrase.length
@field_pages, @fields = paginate(:fields, :order => ‘label DESC’,
:conditions => [ ‘id NOT IN (SELECT field_id FROM
templatecollections WHERE imotemplate_id = ?)’, @imotemplate.id ],
:per_page => 10)
else
@field_pages, @fields = paginate(:fields, :order => ‘label DESC’,
:conditions => [ ‘LOWER(label) LIKE ? AND id NOT IN (SELECT
field_id FROM templatecollections WHERE imotemplate_id = ?)’, ‘%’ +
@phrase.downcase + ‘%’, @imotemplate.id ],
:per_page => 10)
end
render(:partial => “fields”)
end

and this is my code in my view:

Zoeken: <%= text_field_tag :searchvalue %>

<%= observe_field(:searchvalue, :frequency => 0.5, :update => :fields, :url => { :action => :search_fields, :template_id => @imotemplate }) %>
<%= render :partial => "fields" %>

this is the code in the partial fields wich should show the results:
<% if @fields.empty? %>

no field found.

<% else %>
    <% for f in @fields %>
  • <%=f.label%> <%= link_to_remote("add", :url => { :action => 'add_field', :id => f, :template_id => @imotemplate }) %>
  • <% end %>
<%= if @field_pages.current.previous link_to_remote("nieuwere", :update => :fields, :loading => "Element.show('loading')", :complete => "Element.hide('loading')", :url => { :action => "search_fields", :id => @raw_phrase, :page => @field_pages.current.previous, :phrase => @phrase, :template_id => @imotemplate }) end %> <%= if @field_pages.current.next link_to_remote("oudere", :update => :fields, :loading => "Element.show('loading')", :complete => "Element.hide('loading')", :url => { :action => "search_fields", :id => @raw_phrase, :page => @field_pages.current.next, :phrase => @phrase, :template_id => @imotemplate }) end %> <% end %>

the thing is in my development.log and server output are no errors and
the search_field method isn’t called. the code of the observer and the
search fields are also rendered in a partial with an ajax request maybe
there is a problem with ajax and observer_fields because i’m using
exactly the same code on another page without it being load with an ajax
request and there are no errors there.

grts
daan poron

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs