jQuery(…).activeform is not a function in Yii

◇◆丶佛笑我妖孽 提交于 2019-12-01 16:46:17

If you include jQuery core libraries manually in your layout file, it could be possible that jQuery gets loaded a second time and overrides the original jQuery object which had the Yii plugins attached.

You should use Yii::app()->clientScript->registerCoreScript('jquery.ui') instead.

You might have loaded the jquery twice in your page, please check the your code in layout/main.php and where ever you have registered jquery. To load the jquery default code in yii is something like as follows

Yii::app()->clientScript

Please check this line, if you are loading jquery here and you might have loaded the jquery in your layout also. Best way to check this is to use html debugger and view page source of the same page where you are getting error.

add this code with yours path to js in head.php

<?php YII_DEBUG === true ? Yii::app()->clientScript->scriptMap = array('jquery.js'=>'/js/jquery-3.3.1.js') : Yii::app()->clientScript->scriptMap = array('jquery.min.js'=>'/js/jquery-3.3.1.min.js') ?>
<?php Yii::app()->getClientScript()->registerCoreScript('jquery'); ?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!