form_for results in a POST operation.  You are checking for
request.xhr? in your controller to render the partial.   Use
remote_form_for instead to get a XHR request.

Pressing an enter key in a text field doesn't submit a form.  The tags
don't add that in.

Regards,
Mukund


On Jan 7, 4:15 pm, Shilo Ayalon <[email protected]>
wrote:
> Mukund wrote:
> > Create a form without a submit tag.   Put in another control on the
> > web page that does $('id_of_my_form').submit(); using a javascript
> > onclick event or whatever.
>
> > Regards,
> > Mukund
>
> Actually, the form doesn't have a submit tag in it, but 2 selection
> lists and a text field (it's a search/filter form). The submission
> happens when you hit enter whilst inside the text field -- I think it's
> something most people do when searching something > think of every visit
> you made to a search engine's page... Rails form_for might have this
> built in, since it immediately looks for 'create' action when hitting
> enter inside the text field.
>
> I thought about simply redirecting it to the same action that filters
> the form (which is actually called via observe_form tag nearby). I'm
> very new to rails, so I'm not sure how to call the action while
> retaining the same view. Here's a brief rundown of my code:
>
> # view
>
> <% form_for :person, :html => { :id => 'people_form' } -%>
>   <%= f.select :id, @people.collect {|p| [p.name, p.id]} %>
>   <%= f.select :gender, [['Male','M'],['Female','F']] %>
>   <%= f.text_field :search, :size => 20 %>
> <% end -%>
>
> <%= observe_form :people_form, :frequency => 2, :update =>
> 'people_table',
>                  :url => { :action => 'search_form', :only_path => false
>
> } %>
>
> <div id="people_table">
>   <table>
>     <%= render :partial => 'person' %> <!--people rows are drawn from
> here -->
>   </table>
> </div>
>
> # controller
>
> def search_form
>   #... get all search params and store in cond
>   @people = Person.find(:all, :conditions => cond)
>   render :partial => 'person' if request.xml_http_request?
> end
>
> How would I call the search_form function on form submit resulting in
> the same view being rendered (similar to what observe_form does)? I
> tried adding :action => 'search_form' to the form_for tag, but it then
> looks for a view of the same name..
>
> --
> Posted viahttp://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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to