งานที่ทำใช้ jQuery plugin ที่จำกัดอยู่ที่ไม่เกินเวอร์ชั่น 2.1.3 เท่านั้น แต่ทุกครั้งที่ update yii โดยใช้คำสั่ง composer update มันจะเปลี่ยนเจคิวรี่เป็นตัว 2.1.4 ทุกครั้ง ต้องมาเปลี่ยนทุกครั้งเลย แก้ได้โดยไปสั่งใช้คอมโพสเซอร์โหลดตัวที่ต้องการมา
- แก้ composer.json เพิ่ม
"require": {
...
"components/jquery": "2.1.3"
...
},
- ไปใช้ command พิมพ์ composer update มันจะโหลดเจคิวรี่มาเก็บไว้ที่ \vendor\components\jquery
- สั่งให้ยีสองโหลด jquery ตัวนี้มาใช้โดยกำหนด
...
'components' => [
...
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => [
'baseUrl' => '@web',
'js' => [
'../../vendor/components/jquery/jquery.min.js',
],
'sourcePath' => null
],
],
],
...
yii จะเปลี่ยน link จาก
<script src="/YiiAdvanced/frontend/web/assets/41df07c8/jquery.js"></script>
เป็น
<script src="/YiiAdvanced/frontend/web/../../vendor/components/jquery/jquery.min.js"></script>
หลังจากนี้ถึงจะอัพเดทกี่ครั้ง jquery ก็จะยังเป็นตัวเดิมอยู่