My observe_form is basically totally limp. I think it should update without
hitting submit button but even if I hit it , it doesn''t change
(doesn''t seem
to post the data).
Can anyone please take a look and see if I"m doing something wrong. TIA
Form:
<% start_form_tag({:action => "livesearch"},
:id => "asearch") %>
<div id="parta">
<fieldset><legend>Category</legend>
<select name="cat",
@params[''cat''][],size="2"
multiple="multiple"><%options_from_collection_for_select
@categories, :id, :name
%></select></fieldset>
<fieldset><legend>State</legend>
<select name="stat",
@params[''stat''][],size="5"
multiple="multiple"><%options_from_collection_for_select
@states, :id, :name
%></select></fieldset>
<fieldset><legend>Terms</legend>
<select name="term",
@params[''term''][],size="5"
multiple="multiple"><%options_from_collection_for_select @terms,
:id, :name
%></select></fieldset>
<fieldset><legend>Title</legend>
<p><span><b>enter in as many titles as you wish seperated by a
comman</b></span></p>
<%= text_field("title", @params[''title''], :size
=> 10) %></fieldset>
<fieldset><legend>City</legend>
<p><span><b>enter in as many cities as you wish seperated by a
comman</b></span></p>
<%= text_field("city", @params[''city''], :size
=> 10) %></fieldset>
<%= submit_tag ''livesearch'' %>
<% end_form_tag %>
</div>
<%= observe_form "asearch",
:frequency => 1,
:update => "table",
:with => "Form.serialize(asearch)",
:complete =>
"Element.show(''table'')",
:url => { :action => "livesearch" } %>
<div id="partb">
<div id="table">
<%= render :partial => "positions_list" %>
</div>
</div>
Controller:
def livesearch
@categories = Category.find(:all, :order => "name")
@states = State.find(:all, :order => "name")
@terms = Term.find(:all, :order => "name")
params[:cat]
params[:stat]
params[:term]
params[:city]
params[:title]
pq = Position.query # the syntax is because I"m using a plugin
CriteriaQuery, a find wrapper.
pq.category_id_in(params[:cat]) if params[:cat]
pq.state_id_in(params[:stat]) if params[:stat]
pq.term_id_in(params[:term]) if params[:term]
pq.city_in(params[:city].split('','')) if params[:city]
pq.title_in(params[:title].split('','')) if params[:title]
@positions = pq.find
if request.xml_http_request?
render :partial => "positions_list", :layout => false
end
end
end
--
http://en.wikipedia.org/wiki/Dark_ambient
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 10/11/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > My observe_form is basically totally limp. I think it should update > without hitting submit button but even if I hit it , it doesn''t change > (doesn''t seem to post the data). > Can anyone please take a look and see if I"m doing something wrong. TIA > > Form: > <% start_form_tag({:action => "livesearch"}, > :id => "asearch") %> > <div id="parta"> > <fieldset><legend>Category</legend> > <select name="cat", @params[''cat''][],size="2" multiple="multiple"><%> options_from_collection_for_select @categories, :id, :name > %></select></fieldset> > > <fieldset><legend>State</legend> > <select name="stat", @params[''stat''][],size="5" multiple="multiple"><%> options_from_collection_for_select @states, :id, :name > %></select></fieldset> > > <fieldset><legend>Terms</legend> > <select name="term", @params[''term''][],size="5" multiple="multiple"><%> options_from_collection_for_select @terms, :id, :name > %></select></fieldset> > > <fieldset><legend>Title</legend> > <p><span><b>enter in as many titles as you wish seperated by a > comman</b></span></p> > <%= text_field("title", @params[''title''], :size => 10) %></fieldset> > > <fieldset><legend>City</legend> > <p><span><b>enter in as many cities as you wish seperated by a > comman</b></span></p> > <%= text_field("city", @params[''city''], :size => 10) %></fieldset> > > <%= submit_tag ''livesearch'' %> > <% end_form_tag %> > </div> > > <%= observe_form "asearch", > :frequency => 1, > :update => "table", > :with => "Form.serialize(asearch)", > :complete => "Element.show(''table'')", > :url => { :action => "livesearch" } %> > > <div id="partb"> > <div id="table"> > <%= render :partial => "positions_list" %> > </div> > </div> > > Controller: > > def livesearch > @categories = Category.find(:all, :order => "name") > @states = State.find(:all, :order => "name") > @terms = Term.find(:all, :order => "name") > > params[:cat] > params[:stat] > params[:term] > params[:city] > params[:title] > > pq = Position.query # the syntax is because I"m using a plugin > CriteriaQuery, a find wrapper. > pq.category_id_in(params[:cat]) if params[:cat] > pq.state_id_in(params[:stat]) if params[:stat] > pq.term_id_in(params[:term]) if params[:term] > pq.city_in(params[:city].split('','')) if params[:city] > pq.title_in(params[:title].split('','')) if params[:title] > @positions = pq.find > > if request.xml_http_request? > render :partial => "positions_list", :layout => false > end > end > end > > Here is the script it''s producing from the page source:<script type="text/javascript"> //<![CDATA[ new Form.Observer(''asearch'', 1, function(element, value) {new Ajax.Request(''/ajaxsearch/livesearch'', {asynchronous:true, evalScripts:true, onComplete:function(request){Element.show(''table'')}})}) //]]> </script> -- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No one ? Alright let me ask this then - when using observe_form does each element have to have it''s own id and name ? Stuart On 10/11/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 10/11/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > My observe_form is basically totally limp. I think it should update > > without hitting submit button but even if I hit it , it doesn''t change > > (doesn''t seem to post the data). > > Can anyone please take a look and see if I"m doing something wrong. TIA > > > > > > Form: > > <% start_form_tag({:action => "livesearch"}, > > :id => "asearch") %> > > <div id="parta"> > > <fieldset><legend>Category</legend> > > <select name="cat", @params[''cat''][],size="2" multiple="multiple"><%> > options_from_collection_for_select @categories, :id, :name > > %></select></fieldset> > > > > <fieldset><legend>State</legend> > > <select name="stat", @params[''stat''][],size="5" multiple="multiple"><%> > options_from_collection_for_select @states, :id, :name > > %></select></fieldset> > > > > <fieldset><legend>Terms</legend> > > <select name="term", @params[''term''][],size="5" multiple="multiple"><%> > options_from_collection_for_select @terms, :id, :name > > %></select></fieldset> > > > > <fieldset><legend>Title</legend> > > <p><span><b>enter in as many titles as you wish seperated by a > > comman</b></span></p> > > <%= text_field("title", @params[''title''], :size => 10) %></fieldset> > > > > <fieldset><legend>City</legend> > > <p><span><b>enter in as many cities as you wish seperated by a > > comman</b></span></p> > > <%= text_field("city", @params[''city''], :size => 10) %></fieldset> > > > > <%= submit_tag ''livesearch'' %> > > <% end_form_tag %> > > </div> > > > > <%= observe_form "asearch", > > :frequency => 1, > > :update => "table", > > :with => "Form.serialize(asearch)", > > :complete => "Element.show(''table'')", > > :url => { :action => "livesearch" } %> > > > > <div id="partb"> > > <div id="table"> > > <%= render :partial => "positions_list" %> > > </div> > > </div> > > > > Controller: > > > > def livesearch > > @categories = Category.find(:all, :order => "name") > > @states = State.find(:all, :order => "name") > > @terms = Term.find(:all, :order => "name") > > > > params[:cat] > > params[:stat] > > params[:term] > > params[:city] > > params[:title] > > > > pq = Position.query # the syntax is because I"m using a plugin > > CriteriaQuery, a find wrapper. > > pq.category_id_in(params[:cat]) if params[:cat] > > pq.state_id_in(params[:stat]) if params[:stat] > > pq.term_id_in(params[:term]) if params[:term] > > pq.city_in(params[:city].split('','')) if params[:city] > > pq.title_in(params[:title].split('','')) if params[:title] > > @positions = pq.find > > > > if request.xml_http_request? > > render :partial => "positions_list", :layout => false > > end > > end > > end > > > > Here is the script it''s producing from the page source: > > > > > <script type > ="text/javascript"> > //<![CDATA[ > new Form.Observer(''asearch'', 1, function(element, value) {new Ajax.Request(''/ajaxsearch/livesearch'', {asynchronous:true, evalScripts:true, onComplete:function(request){ > Element.show(''table'')}})}) > //]]> > </script> > > > > > > -- > http://en.wikipedia.org/wiki/Dark_ambient >-- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---