Yii Framework Forum: In Active Form, How To Bind Ajax To Onmouseover Instead Of Onchange? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

In Active Form, How To Bind Ajax To Onmouseover Instead Of Onchange? Rate Topic: -----

#1 User is offline   Rick's 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 18-October 13

Posted 26 November 2013 - 02:55 AM

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?
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,600
  • Joined: 04-March 10
  • Location:UK

Posted 26 November 2013 - 05:56 AM

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?
0

#3 User is offline   Rick's 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 18-October 13

Posted 26 November 2013 - 09:21 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users