Observe_field w/check_box (how do you capture unchecked even

Hi: Does observe_field work w/check_box?

When a checkbox is checked, all works. When it is unchecked, I get
“undefined” for params[:option].

more info on what I’m using:

my check_box method produces this:

my observe_field is:

<%= observe_field “option_#{option}”,
:update => ‘commandLine’,
:url => {:action => ‘updateCommand’},
:with => ‘option’,
:on => ‘click’ %>

For one of my applications the observer passes “1” when it is checked
and
“undefined” when it isn’t. “undefined” should probably be “0”, but you
can
still tell whether or not it is checked.

-Jonathan.

For one of my applications the observer passes “1” when it is checked and
“undefined” when it isn’t. “undefined” should probably be “0”, but you can
still tell whether or not it is checked.

Maybe… but since there’s no “unchecked_value” attribute it really is
undefined… I think you’d be safer testing to see…

if params[:option] != “1” then…

where “1” is the value of the ‘value’ attribute. Cause some web browser
might just decide to start returning false or nil or 0 instead of
‘undefined’ so you’re test for ‘undefined’ would then fail…

Just a thought.

I forgot to mention I have lots of checkboxes for this view, so I can’t
determine which box the uncheck was triggered from because of the
‘undefined’.

From: [email protected]
[mailto:[email protected]] On Behalf Of Jonathan V.
Sent: Tuesday, October 17, 2006 11:03 PM
To: [email protected]
Subject: [Rails] Re: observe_field w/check_box (how do you capture
unchecked
event?)

For one of my applications the observer passes “1” when it is checked
and
“undefined” when it isn’t. “undefined” should probably be “0”, but you
can
still tell whether or not it is checked.

-Jonathan.

On 10/18/06, Tate H. [email protected] wrote:

Hi: Does observe_field work w/check_box?

When a checkbox is checked, all works. When it is unchecked, I get
“undefined” for params[:option].

[…]