Download the PHP package letsjump/yii2-easy-ajax without Composer

On this page you can find all versions of the php package letsjump/yii2-easy-ajax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-easy-ajax

yii2-easy-ajax

Relax your keyboard with Yii2 EasyAjax

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.

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:

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Configuration

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

To use the integrated Gii generator, add the following code to your application configuration:

Please note: The integrated Gii generator allows you to generate the code for AJAX as well as the standard CRUD.

Usage

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:

or

NOTE:

To explore any other Html attributes available and to know all the details, please refer to the guide

2. Responses

The controller actions interacting with EasyAjax should return a Json array, and they only need to contain one or more EasyAjax methods in their response array.

In the following example...

... EasyAjax will:

Here are the available methods in detail:

Modals

With EasyAjax, you can fire and configure a Bootstrap Modal using the following: EasyAjax::modal(content, title, _formid, size, footer, options)

It is also available a method to remotely close a Modal which is actually open in the UI:

You can edit the modal layout and many other settings. Please refer to the guide for all the available options.


Notify

EasyAjax Notify allows to control the Bootstrap Notify plugin. The plugin assets (bootstrap-notify.js and animate.js) are bundled within EasyAjax.

Tip: You can disable the asset inclusion if it is already bundled in your application

To fire a Notify, you can use \letsjump\easyAjax\EasyAjax::notify(message, title, settings). In the settings parameter, you should specify the type of notification displayed (Notify::TYPE_INFO (blue), Notify::TYPE_SUCCESS (green), Notify::TYPE_WARNING (yellow) or Notify::TYPE_DANGER (red)).

To speed up your coding, I have also added some shortcut methods for the most common notification types: EasyAjax::notifyInfo(message), EasyAjax::notifySuccess(message), EasyAjax::notifyWarning(message), EasyAjax::notifyDanger(message).

Example:

Note: Actually notify doesn't refer to the Yii2 flash message session array. Please open an issue if you think it is needed.

Refer to the guide for all the available options and template manipulation.


Pjax Reload

The EasyAjax PjaxReload (EasyAjax::pjaxReload(['#myPjaxID0', '#myPjaxID1', ...])) method allows to reload one or more Pjax containers.

Refer to the guide for detailed informations.


Form Validation

The form validation (EasyAjax::formValidation(['#my-form-id'=>ActiveForm::validate(MyModelClass)])) method allows to display the validation results for the specified form. It will send the validation results for each form field specified by the #form-id attribute to display its error messages.

Refer to the guide for detailed informations.


Ajax CRUD with Gii

The bundled Gii generator within EasyAjax allows you to instantly create the Ajax CRUD controller and views.

This will generate a CRUD schema which is identical to the Yii2 original one, with an added actionModal($id=null) into the controller code, plus its relative myViewFolder/_modal.php view in charge of creating or updating the data in an Ajax modal.

You can switch the CRUD behavior to Ajax modal by simply setting the 'modal' parameter of the integrated ActionColumn method :

BONUS: Deleting a record doesn't imply a complete page refresh, therefore the GridView pagination will not be affected.

Refer to the guide for all the available options.


Ajax Tabs

EasyAjax Tab (EasyAjax::tab('tab-id', 'content to inject')) is a simple and very basic way to update the content of a Bootstrap Tab with an ajax response from a controller.

View

In the \yii\bootstrap\Tabs widget for each tab item, you must:

Controller

Just include the EasyAjax method EasyAjax::tab(tab-id, content) into the controller action response array:

Warning: tab-id must be specified without the hashtag (#).

Refer to the guide for all the available options.


Content replace

EasyAjax ContentReplace(['#container1-id'=>'New content', '#container2-id'=>'New content', ...]) replaces the content of a specific Html tag with the code sent by the EasyAjax response. It uses the jQuery.html() standard method.

Refer to the guide for detailed informations.


Confirms

You can use the EasyAjax confirm('message', 'url') method to fire a Javascript Window confirm() from a controller action. By clicking on the "OK" button it will fire an Ajax request to the action specified in the url parameter.

Refer to the guide for detailed informations.

Security

See SECURITY.md

Contributing

See CONTRIBUTING.md

Credits

Yiisoft for the best PHP framework for large-scale application (my own opinion), Twitter Bootstrap, and the Bootstrap Notify plugin. The Code of Conduct is adapted from the Contributor Covenant

License

See LICENSE.md


All versions of yii2-easy-ajax with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ~2.0.0
bower-asset/remarkable-bootstrap-notify Version ~3.1.0
bower-asset/animate-css Version ~3.7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package letsjump/yii2-easy-ajax contains the following files

Loading the files please wait ....