I have a form that works perfectly. Now, when i add the following code, it throws the jQuery(“body”).undelegate is not a function error.
<?php
echo CHtml::dropDownList(
'country_id',
'',
array('0'=>'Choice One',
'1'=>'USA',
'2'=>'France',
'3'=>'Japan',),
array(
'ajax'=>array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('users/aTest'),
'success'=>'function(data){alert(data)}',
)));
?>
In UsersController, I have the following action (and it is also included in the accessRules)
public function actionATest()
{
echo "this is a test";
}
When i expand the error, a specific line of code is highlighted (the second one)
jQuery(function($) {
$(".errorDisplay").animate({opacity: 1.0}, 3000).fadeOut("slow");
jQuery('body').undelegate('#country_id','change').delegate('#country_id','change',function(){jQuery.ajax({'type':'POST','url':'/index.php/users/unaPrueba','success':function(data){alert(data)},'cache':false,'data':jQuery(this).parents("form").serialize()});return false;});
Any ideas??? Anybody had this problem? Couldn’t find it anywhere!
Check that your jQuery includes aren’t conflicting. If you’re adding jQuery with your own tag, Yii might still be automatically adding another jQuery file you weren’t expecting, as part of its built-in assets (see this question). You can disable Yii’s jQuery: