Here's what I see happening in Safari: Once you tab into the form element and start changing the selection with the arrow keys, the list of options stays open until you hit Return or Tab to blur away from the field. At that moment, the change event fires, and the observer sees it.

In Firefox, navigating with the arrow keys causes the number to change in the picker, but until you actually blur away from the form element by pressing Return, the change event doesn't fire. Once you do, the event fires, exactly the same as Safari.

If you want to observe the field on a regular schedule, rather than listen for an event, you can get around this problem:

new Form.Element.Observer(
  'foo',
  0.2,  // 200 milliseconds
  function(el, value){
    $('bar').update(value)
  }
)

Hope this helps,

Walter

On May 5, 2010, at 12:28 PM, Hari wrote:

Hi,

Some more inputs...

- onchange event works fine in IE but not in firefox (doesn't fire a
change event when using keyboard to change values).
- both onchange and onkeyup events are fired when your event handler
has an alert box (you loose focus and an keyboard event with
keycode=38 is fired along with onChange event)
- note both events are fired only when u have an alert in event
handler else only key event is fired...

Can someone tell me if this could be done... how can avoid 2 events
getting fired and still have alert in my event handler....

Hari

On May 5, 6:48 pm, Walter Lee Davis <[email protected]> wrote:
Doesn't the change event fire as soon as the select loses focus and no
longer has the same value it started with? I thought that was the
basis for the event itself. Can you post an example that fails to fire
the change event when modified with the keyboard?

Walter

On May 5, 2010, at 8:56 AM, Hari wrote:





Hi,

I have a simple html select and attached a javascript to fire an event
when value changes...
My html

      <select id="mySelectBox">
           <option>1</option>
           <option>2</option>
           <option>3</option>
           <option>4</option>
       </select>

My Js
 $('mySelectBox').observe("keyup",myEventHandler);  // this is added
for keyboard support for firefox to recognise selection change using
keyboard
 $('mySelectBox').observe("change",myEventHandler); // this is the
actual change
 function myEventHandler(){
     alert('ping');
 }

If I have both 2 events are fired...If I have either of the two
statements, things work fine but the other event is not fired. Is
there a way to get around this problem.

Thanks and Regards,
Hari

--
You received this message because you are subscribed to the Google
Groups "Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
.
To unsubscribe from this group, send email to 
[email protected]
.
For more options, visit this group 
athttp://groups.google.com/group/prototype-scriptaculous?hl=en
.

--
You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] . To unsubscribe from this group, send email to [email protected] . For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en .

--
You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] . To unsubscribe from this group, send email to [email protected] . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en .


--
You received this message because you are subscribed to the Google Groups "Prototype 
& script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to