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:
<p><label for="searchvalue">Zoeken:</label>
<%= text_field_tag :searchvalue %></p>
<%= observe_field(:searchvalue,
:frequency => 0.5,
:update => :fields,
:url => { :action => :search_fields, :template_id =>
@imotemplate }) %>
<div id="fields">
<%= render :partial => "fields" %>
</div>
</div>
this is the code in the partial fields wich should show the results:
<% if @fields.empty? %>
<p>no field found.</p>
<% else %>
<ul>
<% for f in @fields %>
<li><%=f.label%> <%= link_to_remote("add",
:url => { :action =>
''add_field'',
:id => f,
:template_id => @imotemplate
}) %></li>
<% end %>
</ul>
<%= 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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---