Observe_field on select

I have an observe_field on a select box. All works well,
EXCEPT…this particular select box is a js masterpiece that allows
it to be editable in selection index 0.

My problem thus is if someone selects the 0th item in the select box,
types in a value, the observe_field still picks it up in my controller
as “” for params[‘channelnotes’].

Is there a way to amend the observe_field to send back whatever the
text is in the select box? (and not just when the user clicks on it to
invoke the change, because then, of course, option 0 text is “”) I
need to somehow just pass the text of the selected item in it whenever
the text itself changes. Does anyone know observe_field on select
boxes well enough to know how to do this? -Janna B

<SELECT name=“channelnotes” id=“channelnotes” style="width:350px;
onKeyDown=“fnKeyDownHandler(this, event);” onKeyUp=“fnKeyUpHandler_A
(this, event); return false;” onKeyPress = “return fnKeyPressHandler_A
(this, event);” onChange=“fnChangeHandler_A(this, event);”>

one two three

<%= observe_field “channelnotes”, :url => {:controller
=> :channels, :action => ‘notesboxchange’ }, :with => ‘channelnotes’ %>

On Thu, 2009-07-09 at 18:34 -0700, JannaB wrote:

My problem thus is if someone selects the 0th item in the select box,
types in a value, the observe_field still picks it up in my controller
as “” for params[‘channelnotes’].

observe_field fires, by default, on the change event. There used to be
an :on option you could use to modify its trigger. Don’t know if it’s
still a valid option though. A little sandbox exercise would tell for
sure. The bigger problem will probably be cross-browser support for
whatever event you end up needing to trigger on for the edit case.
Here’s a compatibility list:
http://www.quirksmode.org/dom/events/index.html

HTH,
Bill

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs