PHPackages                             letsjump/yii2-easy-ajax - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. letsjump/yii2-easy-ajax

ActiveYii2-extension[Admin Panels](/categories/admin)

letsjump/yii2-easy-ajax
=======================

EasyAjax are a bunch of Yii methods that minimize the amount of code you need to write to interact with Ajax CRUD, notifies, modals, tabs, pjax-reloads, form validations among others...

v1.0.6(5y ago)5424[1 issues](https://github.com/letsjump/yii2-easy-ajax/issues)MITPHP

Since Oct 25Pushed 4y ago2 watchersCompare

[ Source](https://github.com/letsjump/yii2-easy-ajax)[ Packagist](https://packagist.org/packages/letsjump/yii2-easy-ajax)[ RSS](/packages/letsjump-yii2-easy-ajax/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (3)Versions (19)Used By (0)

yii2-easy-ajax
==============

[](#yii2-easy-ajax)

Relax your keyboard with [Yii2 EasyAjax](https://yii.beintech.it/)

EasyAjax are a bunch of Yii methods that minimize the amount of code you need to write to interact with Bootstap UI and with Javascript in general.

[Notifies](#notify), [modals](#modals), [tabs](#ajax-tabs), [pjax-reloads](#pjax-reload), [form validation](#form-validation) among others can now be set up and launched with only a line of code into the controller's action response.

For example, `EasyAjax::modal('My modal content')` opens a modal with "My modal content" as *content*, while `EasyAjax::reloadPjax(['#p0'])` reloads the `pjax-container` identified by `id="p0"`

EasyAjax further provides:

- Complete and ready-to-use **ajax CRUD**, thanks to the integrated [Gii generator](#Ajax-CRUD-with-Gii)
- Fully configurable options both globally and action-specific
- Customizable HTML templates
- Extensible with your own methods

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

`composer require --prefer-dist letsjump/yii2-easy-ajax`

or add

`"letsjump/yii2-easy-ajax": "~1.0.0"`

to the `require` section of your composer.json.

Configuration
-------------

[](#configuration)

To use this extension, add the following code to your web application configuration (config/web.php):

```
'components' => [
    'easyAjax' => [
        'class' => 'letsjump\easyAjax\EasyAjaxBase',
        'customOptions' => [
            /* refer to plugin documentation */
        ]
    ],
]
```

To use the integrated [Gii generator](#Ajax-CRUD-with-Gii), add the following code to your application configuration:

```
if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => \yii\gii\Module::class,
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['127.0.0.1', '::1', /** your IPs */],
        'generators' => [
            'crud' => [
                'class'     => 'letsjump\easyAjax\gii\crud\Generator',
                'templates' => [ //setting for out templates
                    'yii2-easy-ajax' => '@vendor/letsjump/yii2-easy-ajax/gii/crud/default',
                ]
            ],
        ],
    ];
}
```

Please note: The integrated [Gii generator](#Ajax-CRUD-with-Gii) allows you to generate the code for AJAX as well as the standard CRUD.

Usage
-----

[](#usage)

- [1. Requests](#1.-Requests)
- [2. Responses](2.-Responses)

### 1. Requests

[](#1-requests)

EasyAjax requests are simple jQuery AJAX requests that need to refer to a controller action appropriately configured:

The easiest way to perform an EasyAjax request to a controller action is adding the `data-yea=1` attribute to the Html tag in charge of the *onclick javascript event*:

```
