observe_field w/check_box (how do you capture unchecked event?)

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:

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’.

[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Jonathan Viney