In Active Form, How To Bind Ajax To Onmouseover Instead Of Onchange?

this is the code:




echo $form->dropDownList($model, 'id', array(

//some data

			)	,

			array(

			 	'ajax' => array(

					'type' => 'POST',

					'url' => $this->createUrl('url'),

					'dataType' => 'json',

					'data' => array('data' => 'js:this.value'),

					'success' => 'function() {

						//success

							}',

		)));



the ajax will be triggered by default event ‘onchange’, now I want to change the event to ‘onmouseover’. How to modify the code?

Looking at the framework code, the onchange handler is hard coded. If you need to respond to a different event, it might be easier to write your own jQuery function.

Why use onmouseover? You’ll end up with lots of updates on a desktop and it probably won’t work at all on mobile or touch devices. It will also fail if someone tabs into the field, which is pretty common. Maybe you should look into updating it on focus?

it is not necessarily to be onmouseover. I am working on some dependent dropdownlists and wondering how the ajax works. Thank u for the answer. I will check over the source code.