Change event for dropdown

Hi,

I’ve got a dropdown with an onchange event handler, but it’s only fired whenever the new value is selected with a mouse click, not by keyboard (I mean receiving the focus and pressing up/down arrow keys). Do you know any workaround?

My code looks like this:




echo $form->dropDownList( $model, 'field',

                CHtml::listData( $dataList, 'id', 'name' ),

                array( 'submit' => '' ) );



Check values sent by the event and process only those which are equivalent to the ASCII code for mouse clicks

You will need to bind your ajax call the the keypress or keyup event.

As an FYI, this is not currently done via the ajax option in the dropdownlist method. So if you are using that functionality you will need to keep that in mind.

Thank you both…

After having a closer look at this behaviour, maybe it’s not a good idea to fire the event whenever the user goes through the dropdown values. It has more sense the actual behaviour: fire the event whenever the control looses the focus (so the user has selected his desired option)