https://github.com/dmstr/yii2-ajax-button
An input widget for Yii 2.0 Framework
https://github.com/dmstr/yii2-ajax-button
Last synced: 8 months ago
JSON representation
An input widget for Yii 2.0 Framework
- Host: GitHub
- URL: https://github.com/dmstr/yii2-ajax-button
- Owner: dmstr
- License: bsd-3-clause
- Created: 2018-10-12T06:47:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-06T09:39:29.000Z (about 4 years ago)
- Last Synced: 2025-06-12T17:11:23.869Z (12 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 4
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Yii 2 Ajax Button
==================
Yii 2 Ajax Button based on "JQuery".
Widget to manage ajax calls for Yii2 Framework
USAGE
-----
Example usage of ajax button widget
Basic usage
```
dmstr\ajaxbutton\AjaxButton::widget([
'method' => 'get',
'url' => ['/path/to/action','name' => 'key']
]);
```
Advanced usage
```
dmstr\ajaxbutton\AjaxButton::widget([
'method' => 'post',
'params' => ['status' => 'active'],
'url' => ['/path/to/action'],
'options' => ['class' => 'btn btn-primary'],
'errorExpression' => new JsExpression('function(resp,status,xhr) {if (xhr.status === 200) {button.html("Success")}}'),
'successExpression' => new JsExpression('function(xhr) {if (xhr.status === 404) {button.html("Error");console.error(xhr.responseJSON)}}')
]);
```
Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download).
Add repository url to the required section of your `composer.json` file.
"repositories": [
{
"type": "git",
"url": "https://github.com/dmstr/yii2-ajax-button.git"
}
],
Either run
`php composer.phar require dmstr/yii2-ajax-button` or `composer require dmstr/yii2-ajax-button`
or add
"dmstr/yii2-ajax-button": "*"
to the required section of your `composer.json` file.