Error how to remove it?

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

I use Pjax and need to change jQuery version, for this I disable the default version:

 'bundles' => [ 'yii\web\JqueryAsset' => false, //отключаем генерацию по умолчанию JQuery ], 

I connect jQuery in layouts :

 <script type="text/javascript" src="/basic/web/assets/build/js/js_min/lib/Jquery/jquery-2.2.2.min.js"></script> 

I tried to connect via AssetBundle and $this->registerJsFile('url/to/file.js', ['position' => yii\web\View::POS_HEAD]);

Everything works fine until I switch to the view module. But layout main is one common to the whole application.

If you still connect the module's View :

 <script type="text/javascript" src="/basic/web/assets/build/js/js_min/lib/Jquery/jquery-2.2.2.min.js"></script> 

But all the scripts will work. But that error still arises.

It seems that there is no such thing in Yii2 2.5 , but there is one in the new one.

Application / Experiments / Reports


1. Attempt, trying to add ( negative result )

 'components' => [ 'assetManager' => [ 'class' => 'yii\web\AssetManager', 'appendTimestamp' => true, //Включаем поддержку версионности 'bundles' => [ 'yii\web\JqueryAsset' => [ 'sourcePath' => null, // do not publish the bundle 'js' => [ 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', ] ], ], 'linkAssets' => false, //генерация прямых ссылок на файлы, без копирование ресурсов ], ], 

2. Attempt ( positive result )

Archive of our application:

1. Our application has one module that does not have its own layout, and by default all its views will be displayed in the base layout of the application itself (I have it main.php).

2. We use JQueryPjax, not the Pjax that is installed in Yii2 by duolt.

3.Connecting jQuery, we do in layout main.php, at the very bottom

 <div class="wrap"> <div id="pjax-container"> <?= $content ?> </div> </div> <script type="text/javascript" src="/basic/web/assets/build/js/js_min/lib/Jquery/jquery-2.2.2.min.js"></script> <script type="text/javascript" src="/basic/web/assets/build/js/js_min/lib/Pjax/jquery.pjax-min.js"></script> <?php $this->endBody() ?> </body> </html> <?php $this->endPage() ?> 

4.If we remove the css class wrap , then again there will be an error when we go into the View module. If we do not remove this class, then there will be no error. Why?

New data

CSS class has nothing to do with it! Only the div plays the role. That is, if it does not exist, there will be an error. Why?

  • @jQuery I do not need a regular jQuery, and I disable it, the version is not the same. - gilo1212
  • @MasterAlex I answered you. - gilo1212

1 answer 1

You can change the jQuery version in the configuration file:

 return [ // ... 'components' => [ 'assetManager' => [ 'bundles' => [ 'yii\web\JqueryAsset' => [ 'sourcePath' => null, // отключение дефолтного jQuery 'js' => [ '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', // добавление вашей версии ] ], ], ], ], ]; 

Brought from official documentation

  • And this code from documentation off works for you? I post my component code in my question. - gilo1212
  • And why the code from off-line documentation should not work? Now I added this code to my working draft and everything is in order; instead of the default jQuery 1.11.3, 2.1.1 was added - MasterAlex
  • But if you remove "//" from a link, as it is in your code, then yes, it does not work - MasterAlex
  • I did and so and so, and added http, after checking that the resource is there. In general, there is not so simple. I redefined the default controller on my own, and when I do not disable Jquery, which is generated by default, going into the view of the module, everything works fine, but when I go into the view of the main application, Jquery is not generated. Very strange ... Now I’ll download another build, where everything is set by default, and I’ll check there. - gilo1212
  • Yes, it works in a clean version of Yii2, the last one is stable. Bloy .... So why it does not work for me, where my project is located. I continue to test ..... I will unsubscribe the results. I feel it is connected with the deforlny controller. - gilo1212