Unavailable to override $jsOptions

I have this code, and the first file, who tries to override the $jsOptions position, is not included on the HTML. What I’m doing wrong?




public $js = [

    'js/custom.js' => ['position' => \yii\web\View::POS_HEAD],

    'js/moment/moment.min.js',

    'js/datepicker/daterangepicker.js',

    'js/custom2.js'

];

public $jsOptions = ['position' => \yii\web\View::POS_END];

[b]

EDIT:[/b] I tried different ways of writing the override, like:

js/custom.js’=>[‘js/custom.js’,[‘position’=>\yii\web\View::POS_HEAD]]

[‘js/custom.js’,[‘position’=>\yii\web\View::POS_HEAD]]

Etc.

None of them overrides the position, instead writes a strange attribute on the script tag:

<script src="/calificaciones/backend/web/assets/d167143c/js/custom.js" 0-position="1"></script>

Overriding is possible from 2.0.7. Have you got this version?

I have 2.0.7 :)

It should be:




public $js = [

    ['js/custom.js', 'position' => \yii\web\View::POS_HEAD],

    'js/moment/moment.min.js',

    'js/datepicker/daterangepicker.js',

    'js/custom2.js'

];

public $jsOptions = ['position' => \yii\web\View::POS_END];



Tried that too. Same behavior.

Are you 100% sure? I’ve tested it and it worked on my project…

Yes I tested, may be some issue with my installation/configuration? Tired of being stuck with this, I created two assetbundles (one for the head and one for the body). But I really wanted to implement this feature. May be next time :)