yidas / yii2-jquery
jQuery Asset Bundle extension with fixed and CDN sources for Yii2 framework
Installs: 16 454
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.6
Provides
This package is auto-updated.
Last update: 2024-11-29 05:21:15 UTC
README
jQuery Extension for Yii 2
jQuery Asset Bundle extension with fixed and CDN sources for Yii2 framework
This is the jQuery extension for Yii framework 2.0. It provides fixed and CDN jQuery distribution assets and thus makes using jQuery in Yii applications extremely easy.
FEATURES
-
No Bower, Composer installation only
-
CDN & fixed assets source provided
-
Version Controll refers to jQuery
INSTALLATION
The preferred install way is through Composer:
composer require yidas/yii2-jquery
Version options refered jQuery release:
composer require yidas/yii2-jquery ~2.0.0
composer require yidas/yii2-jquery ~3.0.0
Or you could edit composer.json
with adding package in require section then run composer update
.
"yidas/yii2-jquery": "*"
CONFIGURATION
Register or depend Asset into your application:
yidas\yii\jquery\JqueryAsset
For example, to register jQuery assets in view :
\yidas\yii\jquery\JqueryAsset::register($this);
Or as dependency in your app asset bundle :
namespace app\assets; use yii\web\AssetBundle; class AppAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ 'css/site.css', ]; public $js = [ ]; public $depends = [ 'yidas\yii\jquery\JqueryAsset' ]; }
Version Control
This extension includes fixed distribution assets for choosing existing version of jQuery, set the version by configuring config
file:
'components' => [ 'assetManager' => [ 'bundles' => [ 'yidas\yii\jquery\JqueryAsset' => [ 'version' => '2.2.4', ], ], ], ],
CDN Asset Mode
You could switch Asset to use CDN distribution by configuring config
file:
'components' => [ 'assetManager' => [ 'bundles' => [ 'yidas\yii\jquery\JqueryAsset' => [ 'cdnVersion' => '2.2.4', 'cdn' => true, ], ], ], ],
Specify a CDN source
You could also specify CDN source you like:
'components' => [ 'assetManager' => [ 'bundles' => [ 'yidas\yii\jquery\JqueryAsset' => [ 'cdn' => true, 'cdnJS' => ['https://code.jquery.com/jquery-2.2.4.min.js'], ], ], ], ],