yidas/yii2-jquery

jQuery Asset Bundle extension with fixed and CDN sources for Yii2 framework

Installs: 919

Dependents: 1

Suggesters: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

3.0.0 2018-09-29 03:17 UTC

README

993323   68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f656e2f7468756d622f392f39652f4a51756572795f6c6f676f2e7376672f32323070782d4a51756572795f6c6f676f2e7376672e706e67

jQuery Extension for Yii 2


jQuery Asset Bundle extension with fixed and CDN sources for Yii2 framework

Latest Stable Version Latest Unstable Version License

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'],
            ],
        ],
    ],

],