I’m using Yii2 and face some unique problem. I have a view which has unique external js file and I don’t want to include it in Asset. Then I tried to include it by using registerJsFile
<?php $this->registerJsFile('js/company-index.js', [yii\web\JqueryAsset::className()]); ?>
And I did view source in browser I got this
<script src="/js/company-index.js" 0="yii\web\JqueryAsset" 1="3"></script>
The js is not working because the dependency is wrong.
How can this happen?
Have you tried to update to last version?
I’ve tested this and my code works fine.
Hi,I refer to try following line of code & enjoy!
<?php $this->registerJsFile(‘js/jquery.jcarousel.min.js’, [‘depends’ => [yii\web\JqueryAsset::className()]]);?>
here no need to add 2’nd param “POS_END” etc. It aotomatically add the js after the jQuery asset .js file.
Check again your registerJsFile, i think it should be like this:
<?php $this->registerJsFile('js/company-index.js', ['depends' => [yii\web\JqueryAsset::className()]]); ?>