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 }) %>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 %>
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