Forum: Ruby on Rails ajax, checkbox

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Patrick G. (Guest)
on 2007-02-05 00:33
Hi,

I'd like to have a list of things with checkboxes in front of each. When
(un)checking the checkbox, a method should be invoked and I'd like to be
able to see a) which checkbox has been changed (best would be a numeric
id) and b) if the checkbox is now on or off.

This is my attempt

<%= start_form_tag({:action => "save"}, :id=>"checkform" ) %>
<%= check_box "checker", "yesno", :id => "boxx" %>
<%= submit_tag "save" %>
<%= end_form_tag %>

  <%= observe_form "checkform",
  :frequency => 1,
  :url => { :action => "save" },
  :with => "sometext=value"
  %>

When I uncheck the checkbox, the action 'save' is invoked and the
parameters look like this:

{"commit"=>"save", "checker"=>{"yesno"=>"0"}, "action"=>"save",
"controller"=>"check"}

(and "yesno" => "1" when checked).



Question: how do I get the id into the parameter list? Would this be the
only way:?

<%= check_box "checker[]", "yesno", :id => "boxx" %>

without the strange line ":with => 'sometext=value'", I won't get any
useful results, why?

(Parameters: {"action"=>"save", "controller"=>"check"})


How should I use the observe_form correctly?

Patrick
Jamez (Guest)
on 2007-02-06 12:21
(Received via mailing list)
Try posting your question on refwell.com. You might get your answer
there
James

On Feb 4, 11:33 pm, Patrick G. <rails-mailing-l...@andreas-
This topic is locked and can not be replied to.