JQuery (...). activeform is not a function in Yii

I am developing a project with Yii.

I need to use jquery ui on many pages of the site. Therefore, I am adding the jquery core library and jquery ui library to the site layout so that I can access them on all pages.

But this causes a problem on pages that have a form (active form). I see this error on firebug:

jQuery(...).activeform is not a function 

why is that? How can I solve it?

Thanks.

+7
source share
3 answers

If you manually include the main jQuery libraries in your layout file, it is possible that jQuery will load again and override the original jQuery object into which the Yii plug-ins were added.

Instead, use Yii::app()->clientScript->registerCoreScript('jquery.ui') .

+12
source

You may have downloaded jquery twice on your page, please check your code in the /main.php layout and where ever you registered jquery. To load the default jquery code in yii, follow these steps:

Yii::app()->clientScript

Please check this line if you download jquery here, and you can also load jquery into your layout. The best way to check this out is to use the html debugger and view the page source on the same page where you get the error.

0
source

add this code with your js path in head.php

 <?php YII_DEBUG === true ? Yii::app()->clientScript->scriptMap = array('jquery.js'=>'/js/vegas/jquery-3.3.1.js') : Yii::app()->clientScript->scriptMap = array('jquery.min.js'=>'/js/vegas/jquery-3.3.1.min.js') ?> <?php Yii::app()->getClientScript()->registerCoreScript('jquery'); ?> 
0
source

Source: https://habr.com/ru/post/946162/