dmstr/yii2-ajax-button

Widget to manage ajax calls for Yii2 Framework

Maintainers

👁 schmunk

Package info

github.com/dmstr/yii2-ajax-button

Type:yii2-extension

pkg:composer/dmstr/yii2-ajax-button

Statistics

Installs: 58 553

Dependents: 1

Suggesters: 0

Stars: 4

Open Issues: 0

1.0.2 2022-05-06 09:38 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 8fc63658af607203f13f8d5d29673936c2da86d1

  • Elias Luhr <e.luhr.woop@herzogkommunikation.de>

cmsextensionyii2

This package is auto-updated.

Last update: 2026-06-06 18:20:45 UTC


README

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.

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.