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 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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to