DarkSlash
(Darkslash)
March 21, 2016, 6:49pm
1
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>
Bizley
(Bizley)
March 21, 2016, 8:49pm
2
Overriding is possible from 2.0.7. Have you got this version?
Bizley
(Bizley)
March 22, 2016, 10:45am
4
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];
DarkSlash
(Darkslash)
March 22, 2016, 12:52pm
5
Bizley:
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.
Bizley
(Bizley)
March 22, 2016, 5:57pm
6
Are you 100% sure? I’ve tested it and it worked on my project…
DarkSlash
(Darkslash)
March 22, 2016, 6:20pm
7
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